Re: Data Transformation Question

2016-10-12 Thread tmountain
Thanks all. Much appreciated! On Wednesday, October 12, 2016 at 11:26:09 AM UTC-4, tmountain wrote: > > Hi, I'm trying to transform a sequence of data to a map, and I'm using the > following pattern. > > (def data [ {:id 1, :name "foo"}, {:id 2, :name "bar"}]) > > (zipmap (map #(:id %) data) data

RE: Data Transformation Question

2016-10-12 Thread Aaron Cummings
You may also want to consider clojure.set/index, though that may not exactly be what you are looking for.  Original message From: tmountain Date: 2016/10/12 11:26 (GMT-05:00) To: Clojure Subject: Data Transformation Question Hi, I'm trying to transform a sequence of dat

Re: Data Transformation Question

2016-10-12 Thread Timothy Baldridge
group-by is slightly different in that it wraps every value in a vector, and those vectors will contain multiple items if there is an id collision. So that may be what the OP wanted, but it also is a change in semantics. I we can simplify the code a bit to (zipmap (map :id data) data) which is abo

Re: Data Transformation Question

2016-10-12 Thread lvh
> On Oct 12, 2016, at 10:26 AM, tmountain wrote: > > Hi, I'm trying to transform a sequence of data to a map, and I'm using the > following pattern. > > (def data [ {:id 1, :name "foo"}, {:id 2, :name "bar"}]) > > (zipmap (map #(:id %) data) data) > > ; result: {1 {:id 1, :name "foo"}, 2 {: