Reputation:
See this example:
Clojure 1.4.0
user=> (def a 1)
#'user/a
user=> (def b 2)
#'user/b
user=> (= [1 2] [a b])
true
user=> (= '(1 2) '(1 2))
true
user=> (= '(1 2) '(a b))
false
Why the last case does not work, and how do I make the last case work without having to convert list to vector?
Thank you!
Upvotes: 6
Views: 474
Reputation: 18556
You are comparing a list containing 1 & 2 with a list containing the symbols a & b. Symbols are legitimate values in Clojure. '(a b) is equivalent to (list 'a 'b) not (list a b).
(= '(1 2) (list a b))
Is probably the comparison you want.
Upvotes: 15