Physics Forums

Physics Forums (http://www.physicsforums.com/index.php)
-   Programming & Computer Science (http://www.physicsforums.com/forumdisplay.php?f=165)
-   -   Lisp : building a list (http://www.physicsforums.com/showthread.php?t=577390)

Mentz114 Feb13-12 10:36 PM

Lisp : building a list
 
I'm a lisp novice, so naturally I've got into a mess trying to do something that would be elementary in a procedural language. I want to return this list

( ( a SIMP) ( (MLIST SIMP) x ) (MLIST SIMP) y ) )

from a func where x,y are args passed to the function. x and y are atoms.

This
(list '( a SIMP) '( (MLIST SIMP) x ) '(MLIST SIMP) y ) )
does not fail but obviously x and y are unevaluated.

This
(list '( a SIMP) ( ('MLIST 'SIMP) x ) ('MLIST 'SIMP) y ) )
complains about an unbound datum.

I tried to delete this thread but I couldn't. A solution is

(setq lo (list '(MLIST SIMP) x))
(setq hi (list '(MLIST SIMP) y))
(setq res (list '(a SIMP) lo hi ))


All times are GMT -5. The time now is 09:13 PM.

Powered by vBulletin Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2014 Physics Forums