The implementation(s) acts a bit counter-intuitive on non-nested maps: FAIL in (deep-merge-test) (test.clj:5) expected: (= (merge {:a 1, :d 1} {:a 2, :c 1}) (deep-merge {:a 1, :d 1} {:a 2, :c 1})) actual: (not (= {:c 1, :a 2, :d 1} {:a 2, :c 1}))
ERROR in (deep-merge-with-test) (Numbers.java:942) expected: (= nil (deep-merge-with + nil nil nil)) actual: java.lang.NullPointerException: null On Wednesday, July 17, 2013 8:53:03 PM UTC+2, JvJ wrote: > > By the way, this is already in contrib: > http://clojuredocs.org/clojure_contrib/clojure.contrib.map-utils/deep-merge-with > > On Wednesday, July 17, 2013 5:42:24 AM UTC-7, Chris Gill wrote: >> >> Thank you for finding and posting this! Been wracking my brain trying to >> figure out a good way to do a full map merge >> >> On Thursday, April 25, 2013 5:26:53 PM UTC-4, Stuart Sierra wrote: >>> >>> Here's a way to do it from the Pedestal demo source >>> code<https://github.com/pedestal/demo/blob/17eeac7a5e50d31eb81901de465f3f1d863f2f01/hammock-cafe/src/hammock_cafe/config.clj#L37> >>> : >>> >>> (defn deep-merge >>> "Recursively merges maps. If keys are not maps, the last value wins." >>> [& vals] >>> (if (every? map? vals) >>> (apply merge-with deep-merge vals) >>> (last vals))) >>> >>> -S >>> >>> >>> >>> On Thursday, April 25, 2013 4:41:33 PM UTC-4, Joachim De Beule wrote: >>>> >>>> Hi list, >>>> >>>> I was searching for an "easy" way to combined nested maps, e.g. as in >>>> >>>> (combine {:foo {:bar "baz"}} {:foo {:x "y"}}) >>>> => {:foo {:bar "baz", :x "y"}} >>>> >>>> I would expect that there is some core map operation to do this, but >>>> neither merge nor unify work as they simply return {:foo {:x "y"}}, and I >>>> don't see anything else. Am I missing something? >>>> >>>> Joachim. >>>> >>> -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.