
pallet.common.map_utils.clj Maven / Gradle / Ivy
The newest version!
(ns pallet.common.map-utils
"Hash map utils")
; by Chouser: from clojure.contrib.map-utils
(defn deep-merge-with
"Like merge-with, but merges maps recursively, applying the given fn
only when there's a non-map at a particular level.
(deepmerge + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4}
{:a {:b {:c 2 :d {:z 9} :z 3} :e 100}})
-> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4}"
[f & maps]
(apply
(fn m [& maps]
(if (every? map? maps)
(apply merge-with m maps)
(apply f maps)))
maps))
© 2015 - 2025 Weber Informatics LLC | Privacy Policy