Created
November 6, 2012 17:27
-
-
Save vasily-kirichenko/4026186 to your computer and use it in GitHub Desktop.
Thread-it data
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
(defmacro thread-it [& [first-expr & rest-exprs]] | |
(if (empty? rest-exprs) | |
first-expr | |
`(let [~'it ~first-expr] | |
(thread-it ~@rest-exprs)))) | |
(def jay {:name "jay fields" :employer "drw.com" :current-city "new york"}) | |
(def john {:name "john dydo" :employer "drw.com" :current-city "new york"}) | |
(def mike {:name "mike ward" :employer "drw.com" :current-city "chicago"}) | |
(def chris {:name "chris george" :employer "thoughtworks.com" :current-city "new york"}) | |
(thread-it | |
[jay john mike chris] | |
(filter (comp (partial = "new york") :current-city) it) | |
(group-by :employer it) | |
(update-in it ["drw.com"] (partial map :name))) | |
=> | |
{"drw.com" ("jay fields" "john dydo"), | |
"thoughtworks.com" | |
[{:name "chris george", | |
:current-city "new york", | |
:employer "thoughtworks.com"}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment