我想知道是否有一种方法可以在Clojure执行时访问线程优先宏的参数值.例如:
(def x {:a 1 :b 2})
(-> x
(assoc :a 20) ;; I want the value of x after this step
(assoc :b (:a x))) ;; {:a 20, :b 1}
Run Code Online (Sandbox Code Playgroud)
我注意到这有效:
(-> x
(assoc :a 20)
((fn [x] (assoc x :b (:a x))))) ;; {:a 20, :b 20}
Run Code Online (Sandbox Code Playgroud)
但还有其他方法吗?