merge

clojure.core

  • (merge & maps)
Returns a map that consists of the rest of the maps conj-ed onto
the first. If a key occurs in more than one map, the mapping from
the latter (left-to-right) will be the mapping in the result.

2 Examples top

  • user=> (merge {:a 1 :b 2 :c 3} {:b 9 :d 4})
    {:d 4, :a 1, :b 9, :c 3}
  • user=> (merge {:a 1} nil)
    {:a 1}
    
    user=> (merge nil {:a 1})
    {:a 1}
    
    user> (merge nil nil)
    nil
    
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:2621 top

(defn merge
  "Returns a map that consists of the rest of the maps conj-ed onto
  the first.  If a key occurs in more than one map, the mapping from
  the latter (left-to-right) will be the mapping in the result."
  {:added "1.0"
   :static true}
  [& maps]
  (when (some identity maps)
    (reduce1 #(conj (or %1 {}) %2) maps)))
Vars in clojure.core/merge:
Used in 0 other vars

Comments top

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