Skip to content

Instantly share code, notes, and snippets.

@skrat
Created August 18, 2014 11:25
Show Gist options
  • Save skrat/1a7c4e7fa5ddcca8c964 to your computer and use it in GitHub Desktop.
Save skrat/1a7c4e7fa5ddcca8c964 to your computer and use it in GitHub Desktop.
Collecting maps' values
user=> (defn map-vals [f m]
#_=> (into {} (for [[k v] m] [k (f v)])))
#'user/map-vals
user=>
user=> (defn collect [ms]
#_=> (apply merge-with concat
#_=> (for [m ms] (map-vals list m))))
#'user/collect
user=>
user=> (collect [{:a 1 :b 2} {:a 11 :c 3}])
{:c (3), :b (2), :a (1 11)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment