Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Lisp : building a list

  1. Feb 13, 2012 #1


    User Avatar
    Gold Member

    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.

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

    (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 ))
    Last edited: Feb 14, 2012
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?
Draft saved Draft deleted

Similar Discussions: Lisp : building a list
  1. What about LISP? (Replies: 11)

  2. Common LISP vs Pascal (Replies: 1)

  3. Emacs Lisp weirdness? (Replies: 6)

  4. AutoCAD Lisp Problem (Replies: 1)