Compose for NewLISP?

Pondering the philosophy behind the language

Compose for NewLISP?

Postby oofoe » Sat Jan 28, 2012 6:30 am

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:

Code: Select all
(setq x 412)
(setq a '((name "Bob")
             (age    x)))


So that:

Code: Select all
(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:

Code: Select all
(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.
oofoe
 
Posts: 60
Joined: Wed Sep 28, 2005 7:13 pm

Re: Compose for NewLISP?

Postby jopython » Sat Jan 28, 2012 10:23 am

jopython
 
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Compose for NewLISP?

Postby Kazimir Majorinc » Sat Jan 28, 2012 2:00 pm

In this particular case you can check expand in manual.
Kazimir Majorinc
 
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia

Re: Compose for NewLISP?

Postby oofoe » Sun Jan 29, 2012 3:16 pm

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.
oofoe
 
Posts: 60
Joined: Wed Sep 28, 2005 7:13 pm


Return to Whither newLISP?

Who is online

Users browsing this forum: No registered users and 1 guest