Skip to content

Instantly share code, notes, and snippets.

@puredanger
Created October 3, 2012 16:18
Show Gist options
  • Save puredanger/3827978 to your computer and use it in GitHub Desktop.
Save puredanger/3827978 to your computer and use it in GitHub Desktop.
(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