Skip to content

Instantly share code, notes, and snippets.

@hyone
Created June 28, 2011 17:52
Show Gist options
  • Save hyone/1051712 to your computer and use it in GitHub Desktop.
Save hyone/1051712 to your computer and use it in GitHub Desktop.
4clojure #63 - Group a Sequence
;; hyone's solution to Group a Sequence
;; https://4clojure.com/problem/63
(fn my-group-by [pred coll]
(reduce
(fn [dict m]
(let [ret (pred m)]
(assoc dict ret (conj (or (dict ret) []) m))))
{} coll))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment