On Mon, Jan 12, 2009 at 5:56 PM, Jason Wolfe <jawo...@berkeley.edu> wrote: > > For mapping across maps I often find the following utility helpful: > > (defn map-map "Like map, but expects f to produce pairs that are > combined to produce a map output." > [f & maps] (reduce #(conj %1 %2) {} (apply map f maps))) > > 1:1 user=> (map-map (fn [[k v]] [k (str v " Mark")]) {:greet > "hello" :farewell "goodbye"}) > {:farewell "goodbye Mark", :greet "hello Mark"}
This is a pattern, isn't it. I've generally used 'for' when I want destructuring and producing vectors. Combined with 'into' you get: (into {} (for [[k v] {:greet "hello" :farewell "goodbye"}] [k (str v " Mark")])) --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---