What does the clojure [] syntax mean?

'()

is syntactic sugar for (quote ())

. But what does it mean '[]

? Quote |

For example:

(use '[clojure.test :as t])

(.get '[a b c] 1)

(.containsAll '[a b c] '[b c])

((fnth 5) '[a b c d e])

      

+3


source to share


1 answer


Exactly. '

is synonymous quote

, therefore

'[a b c]

      

just

(quote [a b c])

      



quote

prevents Clojure code from being evaluated, so quoting the entire vector is essentially the same as quoting every element of it:

['a 'b 'c]

      

It allows you to create a character vector without an explicit function call symbol

:

[(symbol "a") (symbol "b") (symbol "c")]

      

+13


source







All Articles