Created
September 20, 2010 22:25
-
-
Save jido/588764 to your computer and use it in GitHub Desktop.
The "feed" macro inserts what follows in the blank. Very handy. Author: chouser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'clojure.walk) | |
(defmacro _>_ [& exprs] | |
(reduce | |
(fn [inner step] | |
(clojure.walk/postwalk-replace {'___ inner} step)) | |
(reverse exprs))) | |
(defn cat [lst, val, cont] #(cont (conj lst val))) | |
(trampoline (_>_ (cat [] 3 ___) (fn [l] (cat l 9 ___)) (fn [l] (println l)))) | |
;[3 9] | |
(_>_ (assoc {:a "aa" :b "bda" :f "foo"} :d ___) (assoc [1 2 nil 7] 2 ___) (- (* 56 9) 403)) | |
;{:d [1 2 101 7], :a "aa", :b "bda", :f "foo"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment