Suppose I have a function
CL-USER> (defun trimmer (seq) "This trims seq and returns a list"
(cdr
(butlast seq)))
TRIMMER
CL-USER> (trimmer '(1 2 3 VAR1 VAR2))
(2 3 VAR1)
CL-USER>
Notice how, due to QUOTE, VAR1 and VAR2 are not resolved. Suppose I want to resolve the symbols VAR1 and VAR2 to their values - is there a standard function to do this?
Backquote is the usual way to interpolate values into a quoted list:
Edited to add: if you want to process a list so that symbols are replaced with their
symbol-value
, then you need a function something like this:This seems like a strange thing to want to do, however. Can you say more about what you are trying to achieve? Almost certainly there's a better way to do it than this.
Do not use
quote
to create a list with variables; uselist
instead:(where
value-of-var1
is the value ofvar1
).Quote
only prevents evaluation of whatever its argument is. If its argument happens to be a list literal, then that is returned. However, to create lists that are not just literals, uselist
. You can use backquote syntax, but that is rather obfuscation in such a case.