Housekeeping: rename `utils/deep-merge` -> `utils/merge-deep`

This commit is contained in:
Peter Taoussanis 2013-07-06 00:54:25 +07:00
parent a5deb8ac2f
commit 0945b83009
2 changed files with 6 additions and 6 deletions

View File

@ -113,7 +113,7 @@
(catch java.io.IOException _))))}}})) (catch java.io.IOException _))))}}}))
(defn set-config! [ks val] (swap! config assoc-in ks val)) (defn set-config! [ks val] (swap! config assoc-in ks val))
(defn merge-config! [& maps] (apply swap! config utils/deep-merge maps)) (defn merge-config! [& maps] (apply swap! config utils/merge-deep maps))
(defn set-level! [level] (set-config! [:current-level] level)) (defn set-level! [level] (set-config! [:current-level] level))

View File

@ -25,12 +25,12 @@
(swap! cache assoc args {:time-cached now :d-result d-result}) (swap! cache assoc args {:time-cached now :d-result d-result})
@d-result)))))) @d-result))))))
(defn deep-merge-with ; From clojure.contrib.map-utils (defn merge-deep-with ; From clojure.contrib.map-utils
"Like `merge-with` but merges maps recursively, applying the given fn "Like `merge-with` but merges maps recursively, applying the given fn
only when there's a non-map at a particular level. only when there's a non-map at a particular level.
(deepmerge-with + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4} (merge-deep-with + {: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 {: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}" => {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4}"
[f & maps] [f & maps]
(apply (apply
@ -40,9 +40,9 @@
(apply f maps))) (apply f maps)))
maps)) maps))
(def deep-merge (partial deep-merge-with (fn [x y] y))) (def merge-deep (partial merge-deep-with (fn [x y] y)))
(comment (deep-merge {:a {:b {:c {:d :D :e :E}}}} (comment (merge-deep {:a {:b {:c {:d :D :e :E}}}}
{:a {:b {:g :G :c {:c {:f :F}}}}})) {:a {:b {:g :G :c {:c {:f :F}}}}}))
(defn round-to (defn round-to