Re: fringe definition
  Home FAQ Contact Sign in
comp.lang.functional only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.functional Profile…
 Up
Re: fringe definition         


Author: xahlee
Date: Aug 7, 2008 06:35

> (setf bin-tree '(4 (2 1 3) (6 5 7)))
> Thus in my view the only fringe nodes (leaves) are 1, 3, 5, and 7.

also note, when in a language where there's isomorphism between the
syntax and the nested list, there's a concept of head.

For example, in pseudo lisp:

(list (list 1 3) (list 5 7))

In this list, the 1,3,5,7 are leafs. Each having index
{1,1}, {1,2}, {2,1}, {2,2}.

Now, the three appearances of “list”, are non-leaf nodes in the tree,
having indexes of: {0}, {1,0}, {2,0}. These positions are called Head
in Mathematica, and the notion of head also appear in lisp.

Now, consider this pseudo lisp:

(4 (2 1 3) (6 5 7))

which is closer to what you gave above. Now, the element at index {0}
is 4, and at {1,0} is 2, and at {2,0} is 6.

The whole expression itself, is still a tree or a nested list. In this
way, we can see that there is a isomorphism between the textual
representation of a tree, and what is actually considered a list
datatype in the lisp-like language.
Show full article (4.40Kb)
1 Comment
Re: fringe definition         


Author: xahlee
Date: Aug 7, 2008 07:01

I hasten to add, that in my previous post, i said that:

«In most lang that supports nested list, such as perl, php, python,
only the leaf nodes holds data. But as you can see the above, in this
lang with regular nested syntax, not only leaf nodes can hold data,
but any node, including non-leaf nodes (heads), can hold arbitrarily
nested data.»

actually, lang such as perl, php, python, javascript, you can actually
have a nested list where the non-leaf nodes also holds arbitrary data.
All you have to do, is to consider that the first element of a list as
the non-leaf nodes (i.e. lisp's “head”).

In langs such as perl etc, assuming 1st element of list as non-leaf
node is not a problem. But in lang with a purely nested syntax, by
assuming the 1st element of list as non-leaf node, i think it
necessarily introduces a more complex model of interpretation if you
still want a isomorphism between the syntax, tree, and list datatype.

Xah
http://xahlee.org/



-------------------------------------------
Show full article (5.42Kb)
no comments