From: Xah
Subject: Re: trees, indexes, and expressions
Date: 
Message-ID: <6e5ni2$peq$1@nntp2.ba.best.com>
This is a question about languages and expression structures. Any comments
will be appreciated.

One thing I found curious is that lisp languages (Scheme) does not rely on
the structure of expression as much as Mathematica. For example, in mma,
there's a collection of functions (e.g. Level, Map, MapAt, MapIndexed,
Apply, Position, MemberQ...etc) that accepts a level spec, so operators can
be directed to act on certain level(s) only. But these functions are absent
in Scheme (or lisp, I think).

Example: Map[f,expr,{-1}] will apply f to leaves of the tree (i.e atoms).
Select[expr,predicate,{-2}] will select parts of expr at level -2 (level 2
counting from leaves to root). Does lisp programing make use of such
construct *AT ALL*? In Scheme, the concept of level isn't there (or not
explored). Am I right to generalize this to all lisp dialects?

I find this fact curious, because I felt that programing that relies on
expression structures are powerful. I am sure I'm strongly biased because
Mathematica is the only language I have a  mastery. I wanted to find out
what other languages do strongly rely on expression structures. Does any of
those purely functional languages like Haskell?

I'm asking this because I'm exploring other languages, and wondered if
there's one with emphasis on structures of expressions like mma. Any comment
appreciated. Thanks.

 Xah, ···@best.com
 http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html
 "morality abets evil"

From: Pierpaolo Bernardi
Subject: Re: trees, indexes, and expressions
Date: 
Message-ID: <6e6i5o$sfo$1@croci.unipi.it>
Xah (···@best.com) wrote:
: This is a question about languages and expression structures. Any comments
: will be appreciated.

: One thing I found curious is that lisp languages (Scheme) does not rely on
: the structure of expression as much as Mathematica. For example, in mma,
: there's a collection of functions (e.g. Level, Map, MapAt, MapIndexed,
: Apply, Position, MemberQ...etc) that accepts a level spec, so operators can
: be directed to act on certain level(s) only. But these functions are absent
: in Scheme (or lisp, I think).

Lisp _does_ rely on expression structure.  It just lacks these
particular library functions that are in Mathematica and that you
like.

: Example: Map[f,expr,{-1}] will apply f to leaves of the tree (i.e atoms).
: Select[expr,predicate,{-2}] will select parts of expr at level -2 (level 2
: counting from leaves to root). Does lisp programing make use of such
: construct *AT ALL*? In Scheme, the concept of level isn't there (or not
: explored). Am I right to generalize this to all lisp dialects?

As far as I know, no Lisp has these functions.  Please note, however,
that should be trivial to write them. 

If they are not in any Lisp the reason, probably, is that nobody found
these functions useful.

Can you supply an example where they are useful?


Sincerely,
Pierpaolo Bernardi
From: Rainer Joswig
Subject: Re: trees, indexes, and expressions
Date: 
Message-ID: <joswig-1203981356050001@kraftbuch.lavielle.com>
In article <············@croci.unipi.it>, ········@cli.di.unipi.it
(Pierpaolo Bernardi) wrote:

> If they are not in any Lisp the reason, probably, is that nobody found
> these functions useful.

I guess they are left out with a reason. They are popular exercises
in Computer Science education. ;-)

-- 
http://www.lavielle.com/~joswig/