summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2009-09-22 20:02:53 -0400
committerRich Hickey <richhickey@gmail.com>2009-09-22 20:02:53 -0400
commit64323d8c6ad4962ac780d4d904b69a891ab312f8 (patch)
tree748c652a7cdbef8b7938e4c35b1f688a425dd067 /src
parente73abece1ebf3a4aba22104ae9452b2b816ab0d7 (diff)
added ->>
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/core.clj11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 3ca580e3..4d915eaa 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -1070,6 +1070,16 @@
(list form x)))
([x form & more] `(-> (-> ~x ~form) ~@more)))
+(defmacro ->>
+ "Threads the expr through the forms. Inserts x as the
+ last item in the first form, making a list of it if it is not a
+ list already. If there are more forms, inserts the first form as the
+ last item in second form, etc."
+ ([x form] (if (seq? form)
+ `(~(first form) ~@(next form) ~x)
+ (list form x)))
+ ([x form & more] `(->> (->> ~x ~form) ~@more)))
+
;;multimethods
(def global-hierarchy)
@@ -4516,3 +4526,4 @@
(if items
(recur (conj ret (first items)) (next items))
ret)))))
+