Skip to content

Commit

Permalink
added ->>
Browse files Browse the repository at this point in the history
  • Loading branch information
richhickey committed Sep 23, 2009
1 parent e73abec commit 64323d8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/clj/clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -4516,3 +4526,4 @@
(if items
(recur (conj ret (first items)) (next items))
ret)))))

0 comments on commit 64323d8

Please sign in to comment.