【发布时间】:2015-07-02 17:22:22
【问题描述】:
我读取了该数据 > 函数 > 宏
假设您想以后缀方式评估代码。
哪种方法更好?
;; Macro
(defmacro reverse-fn [expression]
(conj (butlast expression) (last expression)))
(reverse-fn ("hello world" println))
; => "hello world"
;; Function and data
(def data ["hello world" println])
(defn reverse-fn [data]
(apply (eval (last data)) (butlast data)))
(reverse-fn ["hello world" println])
; => "hello world"
谢谢!
【问题讨论】:
标签: clojure