Trees

Rustom Mody rustompmody at gmail.com
Tue Jan 20 14:51:41 CET 2015


On Tuesday, January 20, 2015 at 7:03:56 PM UTC+5:30, Rustom Mody wrote:
> On Tuesday, January 20, 2015 at 11:38:27 AM UTC+5:30, Terry Reedy wrote:
> > On 1/19/2015 5:06 PM, Zachary Gilmartin wrote:
> > > Why aren't there trees in the python standard library?
> > 
> > Sequences nested withing sequences can be regarded as trees, and Python 
> > has these.  I regard Lisp as a tree processing languages, as it must be 
> > to manipulate, for example, code with nested structures.
> 
> Yeah python has trees alright.

It may be best to read my example above in this order:
1. See the picture at http://www-math.ucdenver.edu/~wcherowi/courses/m4408/gtln8.html

2. Take the python representation of that

>>> t
[I, 6, [I, 2, [L, 1], [I, 4, [L, 3], [L, 5]]], [I, 8, [L, 7], [L, 9]]] 

Indent that a bit:

[I, 6, 
   [I, 2, 
       [L, 1], 
       [I, 4, 
           [L, 3], 
           [L, 5]]], 
   [I, 8, 
       [L, 7], 
       [L, 9]]] 

Now compare with the picture above
Only catch is you must see it 'lying down'
Shouldn't be too hard given that we've all got used to seeing :-) as a smiley :-)



More information about the Python-list mailing list