• (->> x form)
  • (->> x form & more)
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.

1 Example top

  • ;; get the sum of the first 10 even squares
    user=> (->> (range)
                (map #(* % %))
                (filter even?)
                (take 10)
                (reduce +))
    1140
    
    ;; this expands to:
    user=> (reduce + (take 10 (filter even? (map #(* % %) (range)))))
    1140
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:1540 top

(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."
  {:added "1.1"} 
  ([x form] (if (seq? form)
              (with-meta `(~(first form) ~@(next form)  ~x) (meta form))
              (list form x)))
  ([x form & more] `(->> (->> ~x ~form) ~@more)))
Vars in clojure.core/->>:
Used in 0 other vars

Comments top

No comments for ->>. Log in to add a comment.