navgeet
navgeet

Reputation: 1007

dolist binds argument to symbols

In this code dolist binds x to symbols 'foo and 'bar.

(dolist (x '(foo bar))
  (print (symbolp x) t))

This is a problem if I want to use values of foo and bar, like:

(dolist (x '(foo bar))
  (print x t))

How to get around it?

Upvotes: 2

Views: 166

Answers (1)

sepp2k
sepp2k

Reputation: 370435

x is bound to the symbols foo and bar because '(foo bar) is a list containing the symbols foo and bar. If you want a list that contains the values of the variables foo and bar, you can use (list foo bar).

Upvotes: 12

Related Questions