Hi,

Am 20.09.2010 um 18:52 schrieb John Cromartie:

>> (def flip-map #(apply zipmap ((juxt vals keys) %)))
>> 
> 
> If I was going to write flip-map it might be a tad longer, but lazy
> and a bit clearer (IMO), with:
> 
>    (defn flip-map [m] (into {} (map (juxt second first) m)))

Is there some specific reason to avoid the most straight-forward solution?

user=> (defn flip-map [m] (zipmap (vals m) (keys m)))
#'user/flip-map
user=> (flip-map {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8})
{8 :h, 7 :g, 6 :f, 5 :e, 4 :d, 3 :c, 2 :b, 1 :a}

Sincerely
Meikel

-- 
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

Reply via email to