With closure
(apply str [\a \b])
and
(apply str '(\a \b))
returns "ab".
(apply str (\a \b))
returns an error.
Why is that?
Because (\a \b)
means "call the function \a
with an argument of \b
", and since the character \a
is not a function, it fails. Note the difference in the following:
user=> (+ 1 2 3) 6 user=> '(+ 1 2 3) (+ 1 2 3)
As a general rule, if you want to write a literal sequence, use a vector instead of a quoted list since the quote will also stop evaluation of the parts inside the list, e.g.:
user=> [(+ 1 2) (+ 3 4)] [3 7] user=> '((+ 1 2) (+ 3 4)) ((+ 1 2) (+ 3 4))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With