Hi (defn f [coll] (into {} (for [{c :c :as m} coll] [(dissoc m :c) c])))
or (defn f [coll] (reduce (fn [r {c :c :as m}] (assoc r (dissoc m :c) c)) {} coll)) hth, Christophe On Wed, Nov 18, 2009 at 2:19 PM, Robert Campbell <rrc...@gmail.com> wrote: > Hey guys, > > I'm having some trouble finding a nice way to perform a map > transformation I need. I need to transform this: > > [ {:a 1 :b 2 :c 3} {:a 4 :b 5 :c 6} {:a 7 :b 8 :c 9} ] > > into this: > > { {:a 1 :b 2} 3 {:a 4 :b 5} 6 {:a 7 :b 8} 9 } > > I wanted to use map, but each f in map only returns one value, so I > couldn't figure it out. Here is what I have now: > > (def result (ref {})) > (for [item coll] > (dosync (alter result assoc (dissoc item :c) (item :c)))) > ; result should now have correct value > > I also wrote a recursive version to build the map without using a ref, > but I feel like I'm missing a simpler way.. > > -- > 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 > -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.cgrand.net/ (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