expand ('foo 'a)

Started by Fritz, October 01, 2009, 01:07:38 PM

Previous topic - Next topic

Fritz

Looking at the "expand" function in manual (http://www.newlisp.org/downloads/newlisp_manual.html#expand">http://www.newlisp.org/downloads/newlis ... tml#expand">http://www.newlisp.org/downloads/newlisp_manual.html#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

#1
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.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Fritz

#2
Quote from: "Kazimir Majorinc"...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

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


> (set 'foo '(d e))
(d e)
> (expand foo 'foo)
(d e)
>


but it would make sense here (not on the top level):


> (set 'bar '(x foo y))
(x foo y)
> (expand bar 'foo)
(x (d e) y)
>


ps: the manual is corrected