Created
November 22, 2011 01:37
-
-
Save ajsharp/1384628 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defn count-reduce | |
[memo obj] | |
(let [key (str (year obj) "/" (month obj))] | |
(if (get memo key) | |
(merge memo {key (inc (get memo key))}) | |
(merge memo {key 1})))) | |
(str | |
(reduce count-reduce {} | |
(map coerce-date | |
(map :created_at coll)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
19:41 (ajsharp) amalloy: looks like merge-with actually merges the values in the two maps, no?
19:41 ambrosebs has left IRC (Remote host closed the connection)
19:42 (TimMc) brehaut: fnil!
19:42 (amalloy) (apply merge-with + (for [obj coll] {(str (year obj) "/" (month obj)) 1}))