验证中...
Languages: Clojure
Latest update 2018-12-09 09:52
deep-merge.clj
Raw Copy
(defn deep-merge [m1 m2]
(let [merge-fn (fn merge-fn [a b]
(if (and (map? a) (map? b))
(merge-with merge-fn a b)
b))]
(merge-with merge-fn m1 m2)))
(let [m1 {:key {:key1 1
:key2 {:a 1}}
:kkk 111}
m2 {:key {:key1 12
:key2 {:b 2}}
:kkk {:kkk1 222}}]
(prn (deep-merge m1 m2)))
;; {:key {:key2 {:b 2, :a 1},
;; :key1 12},
;; :kkk {:kkk1 222}}

Comment list( 0 )

You need to Sign in for post a comment

Help Search