(setq a 2)
(setq l '(a b c))
(car l)
Got a
when evaluating this, and why its value not 2
?
(setq a 2)
(setq l '(a b c))
(car l)
Got a
when evaluating this, and why its value not 2
?
The single quote inhibits evaluation of elements in the list. An alternative form would be to use the function list
instead of single quote, or use a backtick and comma combination. See:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html
(progn
(setq a 2)
(setq l `(,a b c))
(car l))
or
(let (a b c l)
(setq a 2)
(setq l (list a b c))
(car l))