ahala
ahala

Reputation: 4793

difference between (list a) and '(a) in Clojure

For the following clojure code,

(def a 1)
'(a)
[a]

why '(a) = (a) and [a] = [1] ?

Upvotes: 1

Views: 95

Answers (1)

omiel
omiel

Reputation: 1593

The quote applies itself to the content of the list as well.

'(a)
;; ~ (quote (a))
;; ~ (list 'a)
;; => (a)

Use (list a) instead.

(list a)
;; => (1)

;; this works too
`(~a)
;; => (1)

See http://clojure.org/special_forms#quote

Upvotes: 4

Related Questions