Say I have a function that returns a quoted list like so:
(defun create-structure (n l)
'(structure (name . n)(label . l)))
I'd like the function to return:
(create-structure foo bar)
-> '(structure (name . foo)(label . bar))
Instead I get as excpected:
-> '(structure (name . n)(label . l))
There are at least two ways to achieve this, Using the backquote syntax or an explicit call to list.
(defun create-structure-1 (n l)
`(structure (name . ,n) (label . ,l)))
(defun create-structure-2 (n l)
(list 'structure (cons 'name n) (cons 'label l)))
The GNU Emacs Lisp Reference provides a good read on the subject: - http://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html#Backquote
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With