Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created March 8, 2017 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/fad38be731c4406e3978054471e2dd34 to your computer and use it in GitHub Desktop.
Save deque-blog/fad38be731c4406e3978054471e2dd34 to your computer and use it in GitHub Desktop.
(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