Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure unquote '(1 2 (+ 1 2))

Tags:

clojure

How should I unquote in the following:

(def a '(1 2 (+ 1 2)))

So that it evaluates to:

(1 2 3)

Doing a:

(def a '(1 2 ~(+ 1 2)))

evaluates as below in the REPL:

(1 2 (clojure.core/unquote (+ 1 2)))

I know I can do a:

(list 1 2 (+ 1 2))

But I was wondering whether there might be some syntax for the purpose.

like image 593
Marcus Junius Brutus Avatar asked Feb 17 '23 13:02

Marcus Junius Brutus


1 Answers

Use ` instead of '. Unquoting does not work with '.

like image 124
sepp2k Avatar answered Feb 27 '23 14:02

sepp2k