mapcat

clojure.core

  • (mapcat f & colls)
Returns the result of applying concat to the result of applying map
to f and colls. Thus function f should return a collection.

2 Examples top

  • user=> (mapcat reverse [[3 2 1 0] [6 5 4] [9 8 7]])
    (0 1 2 3 4 5 6 7 8 9)
    
  • user=> (mapcat (fn [[k v]] 
                     (for [[k2 v2] v] 
                       (concat [k k2] v2)))
             '{:a {:x (1 2) :y (3 4)}
               :b {:x (1 2) :z (5 6)}})
    
    ((:a :x 1 2) (:a :y 3 4) (:b :x 1 2) (:b :z 5 6))
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/map

    Returns a lazy sequence consisting of the result of applying f to the

  • 0
    clojure.core/concat

    Returns a lazy seq representing the concatenation of the elements in

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2453 top

(defn mapcat
  "Returns the result of applying concat to the result of applying map
  to f and colls.  Thus function f should return a collection."
  {:added "1.0"
   :static true}
  [f & colls]
    (apply concat (apply map f colls)))
Vars in clojure.core/mapcat:
Used in 0 other vars

Comments top

No comments for mapcat. Log in to add a comment.