Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created November 22, 2011 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ajsharp/1384628 to your computer and use it in GitHub Desktop.
Save ajsharp/1384628 to your computer and use it in GitHub Desktop.
(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))))
@ajsharp
Copy link
Author

ajsharp commented Nov 22, 2011

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}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment