Hi Michał, The underlying problem (using merge-with plus an accumulating fn) has come up before on the list. One proposal was a variant of merge-with that always applies the merge function [1].
I think the underlying issue needs to be solved at merge-with, not at the map data structure. In other words, why isn't merge-with like reduce, with a second variant taking an initial seed value [2]? Useful? Am I crazy? (Not mutually exclusive.) Stu [1] http://groups.google.com/group/clojure/browse_thread/thread/b8a5195439c7b435 [2] http://gist.github.com/468449 > Hi Group, > > I've just written an implementation of a persistent map which provides > a default value -- fixed at creation time the way it's currently > implemented -- and claims that it .containsKey every key thrown at it. > The code is here: > > http://gist.github.com/468332 > > As mentioned in a comment, the small parts which aren't entirely > trivial are taken more or less directly from emit-defrecord (minus its > generic nature). > > My primary purpose was to devise a helper map type for use with > merge-with, so that I can say > > (merge-with conj (DefaultMap. [] {}) {:a 1} {:a 2} {:a 3}) > > and get back > > {:a [1 2 3]} > > Any comments? In particular, do the implementations of hashCode, > equals and getLookupThunk look alright? > > Sincerely, > Michał > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > [email protected] > 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 post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
