From: Xah
Subject: tree forms (was: Parsing lisp expr)
Date: 
Message-ID: <67lgv9$9vh$3@nntp1.ba.best.com>
Last week I asked a question in several news groups about converting between
lisp and Mathematica expressions. I wrote:

>  For simplicity, let's say all atoms are just alphanumerics. Here is a
sample
>  expression,
>
>  ((f 1 19) f2 (g h (2 5 9) 3))
>
>  I want to bring out any of such expression's head outside the parenthesis
>  and then change the paren to brackets, e.g. (f 1 2 3) becomes f[1 2 3].
The
>  above sample becomes
>
>  f[1 19][f2 g[h 2[5 9] 3]]
>
> ... and I want to do the converse.

The bracketed form is the canonical form of expression in Mathematica. I
wanted to do the conversion is because I want to find a formal isomorphism
between the two forms. And the reason I want to do that is because I wish to
have a *precise* understanding of Mathematica's tree structure, which should
enable me to implement many of mathematica's functions in Scheme or
Mathematica itself. (The functions I have in mind are: Level, Part, Through,
Transpose, Outer, Map, MapIndexed,...etc.)

So, let me ask directly: Where can I find an exposition that analyze these
two forms? (or tree representation in general) Their pro and cons? Which is
better? The lisp form is more tree-like visually, but the Mathematica form
isn't without logical merits. For instance, because the head has special
semantics attached, therefore it should stand out, as in sin(x) instead of
(sin x) or list(1 2 3) instead of (list 1 2 3).

I'd very much appreciate web resources or direct replies, otherwise, pointer
to printed resource are also welcome. Thanks in advance.

 Xah, ยทยทยท@best.com
 http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html
 "I'm a programer, you're a programmmmmer."