You may also want to consider clojure.set/index, though that may not exactly be 
what you are looking for. 

-------- Original message --------
From: tmountain <tinymount...@gmail.com> 
Date: 2016/10/12  11:26  (GMT-05:00) 
To: Clojure <clojure@googlegroups.com> 
Subject: Data Transformation Question 

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 {:id 2, :name "bar"}}
Is this the most idiomatic way to accomplish this transformation? If not, what 
is?
Thanks,Travis



-- 

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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to