验证中...
语言: Clojure
最后更新于 2017-07-27 18:33
deep-merge.clj
原始数据 复制代码
(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}}

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助

12_float_left_people 12_float_left_close