Created
October 3, 2012 16:18
-
-
Save puredanger/3827978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def input [{:name "jay fields", :current-city "new york", :employer "drw.com"} | |
{:name "john dydo", :current-city "new york", :employer "drw.com"} | |
{:name "mike ward", :current-city "chicago", :employer "drw.com"} | |
{:name "chris george", :current-city "new york", :employer "thoughtworks.com"}]) | |
;; I have some more elegant impls of this but I didn't want to suck in my util lib | |
(defn mod-vals [f m] | |
(reduce-kv (fn [r k v] (assoc r k (map f v))) | |
{} | |
m)) | |
;; group, then modify the records | |
(mod-vals :name (group-by :employer input)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment