On 26.07.2013 00:34, Brian Craft wrote:
> Is there a better way to do this, making a map of certain keys from a
> list of maps?
> 
>> (apply hash-map (mapcat (fn [x] [(x :a) (x :b)]) [{:a "blah" :b "ack"}
> {:a "red" :b "blue"}]))
> {"red" "blue", "blah" "ack"}

Here's another way:

    (let [xs [{:a "blah", :b "ack"} {:a "red", :b "blue"}]]
      (zipmap (map :a xs) (map :b xs)))
    ;= {"red" "blue", "blah" "ack"}

-- 
Timo

-- 
-- 
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/groups/opt_out.


Reply via email to