Created
May 16, 2019 10:30
-
-
Save henryw374/a4cc98552c73a40881e4f71c83c603c3 to your computer and use it in GitHub Desktop.
clojure index-by
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
(ns corr.core | |
(:require [medley.core :as m])) | |
(defn index-by [f coll] | |
(->> coll | |
(group-by f) | |
(m/map-vals (fn [xs] | |
(assert (= 1 (count (take 2 xs)))) | |
(first xs))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment