After playing a while with quote/unquote, I wanted to do a trick, but it didn't want to be done. Here's what I did and what come out :
user=> (let [x '#(inc 1)] `(开发者_C百科1 ~x))
(1 (fn* [] (inc 1)))
But what I wanted was :
(1 2)
Can you help me do that ? :)
And also explain what "part" of Clojure you are using...
You can use eval
:
user=> (let [x `(inc 1)] (eval `(list 1 ~x))) (1 2)
Or more conventionally:
user=> (defmacro foo [x] `(list 1 ~x)) #'user/foo user=> (foo (inc 1)) (1 2)
This will work like you want it to:
user> (let [x (#(inc 1))] `(1 ~x))
;=> (1 2)
精彩评论