expand ('foo 'a)

Q&A's, tips, howto's
Locked
Fritz
Posts: 66
Joined: Sun Sep 27, 2009 12:08 am
Location: Russia

expand ('foo 'a)

Post by Fritz »

Looking at the "expand" function in manual (http://www.newlisp.org/downloads/newlis ... tml#expand):

(set 'x 2 'a '(d e))
(set 'foo 'a)
(expand 'foo 'a) → (d e)
(expand '(a x b) 'x) → (a 2 b)
(expand '(a x (b c x)) 'x) → (a 2 (b c 2))
(expand '(a x (b c x)) 'x 'a) → ((d e) 2 (b c 2))

I have some strange results trying to repeat it. (expand 'foo 'a) gives me only "foo"

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Post by Kazimir Majorinc »

It is OK, because foo is expression that doesn't contain a, so there is nothing to expand. The fact that value of foo is a shouldn't matter.

So, error is in manual.

Expression (expand foo 'a) should evaluate to (d e). And it does.

Fritz
Posts: 66
Joined: Sun Sep 27, 2009 12:08 am
Location: Russia

Post by Fritz »

Kazimir Majorinc wrote:...foo is expression that doesn't contain a, so there is nothing to expand.
Is there a way to expand "(d e)" from foo?

(expand foo 'a) works, but I suspect, it just shows us a.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

yes, you can expand on the top level, but there is not much usage for that:

Code: Select all

> (set 'foo '(d e))
(d e)
> (expand foo 'foo)
(d e)
> 
but it would make sense here (not on the top level):

Code: Select all

> (set 'bar '(x foo y))
(x foo y)
> (expand bar 'foo)
(x (d e) y)
>
ps: the manual is corrected

Locked