Reputation: 109
I need to know what the difference between quote and a list. For example:
cl-prompt> (equal (first (list * 1 2)) *)
T
cl-prompt> (equal (first '(* 1 2)) *)
NIL
I don't get what's the problem.
Upvotes: 3
Views: 96
Reputation: 8421
When used as a variable *
refers to the last result printed to the repl.
CL-USER> (+ 4 4)
8
CL-USER> *
8
In the first one, both asterisks are unquoted, so they are treated as variables rather than symbols (their value being whatever you evaluated before that line). They are the same variable, so of course EQUAL
.
CL-USER> (list * 1 2)
(8 1 2)
In the second one, the first asterisk is a quoted symbol, while the second is a variable with the value T
. The symbol *
is not EQUAL
to T
, so it returns NIL
CL-USER> '(* 1 2)
(* 1 2)
Upvotes: 5