1

I have code like this:

(let* ((l1 '(1 2 3))
       (l2 '(4 5 6))
       (l3 '(7 8 9))
       (ml '(l1 l2 l3)))

  (dolist (l ml)
    (message "%s" l)
    (dolist (e l)
      (message "%s" e)))) 

But it does not work, why?

2

The single quote inhibits evaluation of what is inside the parentheses.

How about?

(let* ((l1 '(1 2 3))
       (l2 '(4 5 6))
       (l3 '(7 8 9))
       (ml `(,l1 ,l2 ,l3)))
  (dolist (l ml)
    (message "%s" l)
    (dolist (e l)
      (message "%s" e))))

Or?

(let* ((l1 '(1 2 3))
       (l2 '(4 5 6))
       (l3 '(7 8 9))
       (ml (list l1 l2 l3)))
  (dolist (l ml)
    (message "%s" l)
    (dolist (e l)
      (message "%s" e))))

See: https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.