Search code examples
lispquote

Lisp - Make a list with variable value


I save the variable value (setf num (+ 4 5)) like this and I save the (setf str '("Hello")).

And then I want make a list like this (setq v '(num str)). However because of the single quote, it doesn't recognize it as a string and not working as expected.

how can i make a list with variable value?


Solution

  • The special operator quote prevents evaluation of your variables.

    You need to call a function (which evaluates its arguments), e.g., list:

    (list num str)
    ==> (9 "Hello")