Created
March 8, 2017 23:39
-
-
Save deque-blog/fad38be731c4406e3978054471e2dd34 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
(defn group-by-reducer | |
"Create a reducer that groups by the provided key" | |
[& key-fns] | |
(fn | |
([] {}) | |
([result] result) | |
([result val] | |
(let [keys ((apply juxt key-fns) val)] | |
(update-in result keys conj val))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment