Arrays and collections / Dictionaries

(def d1 {1 "one"})
(def d2 {2 "two"})
(def d3 {3 "three"})

(def d-all (merge d1 d2 d3))
; d-all is {1 "one", 2 "two", 3 "three"} — a new map, d1 is untouched

; when two maps hold the same key, the rightmost one wins
(def clash (merge {:a 1 :b 2} {:b 99}))
; clash is {:a 1, :b 99}

; merge-with settles the clash by a function instead
(def summed (merge-with + {:a 1 :b 2} {:b 99}))
; summed is {:a 1, :b 101}

(println "d-all is" (pr-str d-all))
(println "d1 is still" (pr-str d1))
(println "clash is" (pr-str clash))
(println "summed is" (pr-str summed))