Re: group-by by multiple keys

2012-01-31 Thread Jay Fields
user=> (def m1 [{:a 1 :b 2 :c 3}{:a 1 :b 2 :c 4}{:a 1 :b 4 :c 3}{:a 1 :b 4 :c 3}]) #'user/m1 user=> (require 'clojure.set) nil user=> (doc clojure.set/index) - clojure.set/index ([xrel ks]) Returns a map of the distinct values of ks in the xrel mapped to a set of the map

Re: group-by by multiple keys

2012-01-31 Thread Cedric Greevey
On Tue, Jan 31, 2012 at 7:41 PM, ron peterson wrote: > hello, > > How to group a collection of maps by multiple keys? > > For example > > (def m1 [{:a 1 :b 2 :c 3}{:a 1 :b 2 :c 4}{:a 1 :b 4 :c 3}{:a 1 :b 4 :c > 3}]) > > (group-by-x [:a :b] m1) > > I'd it like to return this: > > [{:a 1 :b 2}[{:a 1

group-by by multiple keys

2012-01-31 Thread ron peterson
hello, How to group a collection of maps by multiple keys? For example (def m1 [{:a 1 :b 2 :c 3}{:a 1 :b 2 :c 4}{:a 1 :b 4 :c 3}{:a 1 :b 4 :c 3}]) (group-by-x [:a :b] m1) I'd it like to return this: [{:a 1 :b 2}[{:a 1 :b 2 :c 3}{:a 1 :b 2 :c 4}], {:a 1 :b 4}[{:a 1 :b 4 :c 3}{:a 1 :b 4 :c 3}]]