Treat Clojure macro as a function

后端 未结 3 2036
后悔当初
后悔当初 2021-01-01 18:33

How can I cause a Clojure macro to act as a function, so I can pass it as an argument for example? I would expect to have to wrap it somehow.

I would not expect the

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-01 19:27

    For the crazy macro make-fn, how about the one below? It should work as well, and hopefully easier to understand.

    (defmacro make-fn [m] 
     `(fn [& args#]
        (eval 
          (cons '~m args#))))
    

提交回复
热议问题