Re: How to merge two ArrayMaps?

2011-05-13 Thread Laurent PETIT
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

Re: How to merge two ArrayMaps?

2011-05-10 Thread Alan
user> (let [inputs (concat e1 e2)] (map (partial apply merge) (vals (group-by :a inputs ({:d "blah", :a 1, :b "b", :c 300} {:d "blah2", :a 2, :b "a", :c 500}) On May 10, 10:10 am, clj123123 wrote: > I wanted to merge ArrayMap in a vector. Is there a way to do that? > I pu

Re: How to merge two ArrayMaps?

2011-05-10 Thread clj123123
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 % f

Re: How to merge two ArrayMaps?

2011-05-10 Thread Jonathan Fischer Friberg
use (merge e1 e2) Jonathan On Tue, May 10, 2011 at 6:11 PM, clj123123 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

How to merge two ArrayMaps?

2011-05-10 Thread clj123123
(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