Compose for NewLISP?

Started by oofoe, January 27, 2012, 10:30:52 PM

Previous topic - Next topic

oofoe

Hi!



I realize that this is probably really easy and trivial...  However! I would like to define an associative list that uses pre-existing variables. Something like this:


(setq x 412)
(setq a '((name "Bob")
             (age    x)))


So that:


(lookup 'age a) -> 412

Of course this doesn't actually work because the "x" is quoted inside the quoted associative list, so it returns x the symbol instead of the value at associative list creation time. This will work, but it's ugly because you have to use different strategies to assemble the individual keys and values:


(setq a (list '(name "Bob")
                   (list 'age x)))


So... Is there any more elegant way to do it?



Thanks!
Testing can show the presence of bugs, but not their absence.

jopython

#1
Try Kazimirs blog.



http://kazimirmajorinc.blogspot.com/2010/02/composition-of-functions-or-macros.html">//http://kazimirmajorinc.blogspot.com/2010/02/composition-of-functions-or-macros.html

Kazimir Majorinc

#2
In this particular case you can check expand in manual.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

oofoe

#3
Thanks for getting back to me!



I should have been more clear -- I was thinking of "compose" not in the computer science or mathematical sense, but rather as a REBOL-style compose operation where it takes a quoted list and looks up certain tagged symbols. It does look like "expand" is the closest match.



Thanks!
Testing can show the presence of bugs, but not their absence.