Hello, I'm not seeing clearly what you're after.
Given your example, it seems that it can be solved just by the following code: => (def e1 [{:a 1 :b "b" :c 300 }{:a 2 :b "a" :c 500 }]) (def e2 [{:a 1 :d "blah"}{:a 2 :d "blah2"}]) #'user/e1 #'user/e2 => (map merge e1 e2) ({:d "blah", :a 1, :b "b", :c 300} {:d "blah2", :a 2, :b "a", :c 500}) (cause map can take more than one coll) So I think the example may not be representative, and I'm missing something ... 2011/5/10 clj123123 <ariela2...@gmail.com>: > I wanted to merge ArrayMap in a vector. Is there a way to do that? > I put this together but wondering it there's already a library for > that. > > (defn merge-by-field > "xt must have field vals unique" > [xs xt field] > (let [fmerge (fn [id s] > (merge s (first (filter #(= id (val (find % field))) > xt))))] > (for [i xs] > (fmerge (field i) i)))) > > (def e1 [{:a 1 :b "b" :c 300 }{:a 2 :b "a" :c 500 }]) > (def e2 [{:a 1 :d "blah"}{:a 2 :d "blah2"}]) > > (merge-by-field e1 e2 :a) > > > output: > ({:d "blah", :a 1, :b "b", :c 300} {:d "blah2", :a 2, :b "a", :c 500}) > > > On May 10, 9:31 am, Jonathan Fischer Friberg <odysso...@gmail.com> > wrote: >> use (merge e1 e2) >> >> Jonathan >> >> >> >> On Tue, May 10, 2011 at 6:11 PM, clj123123 <ariela2...@gmail.com> wrote: >> > (def e1 {:a 1 :b "b" :c 300 }) >> > (def e2 {:a1 :d "blah"}) >> >> > how to merge to get that? >> >> > {:a 1 :b "b" :c 300 :d "blah"} >> >> > also is there a way to merge if the ArrayMap was in a vector? >> >> > Thanks. >> >> > -- >> > 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- Hide quoted text - >> >> - Show quoted text - > > -- > 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 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