Skip to content

Instantly share code, notes, and snippets.

@igrishaev
Created January 11, 2024 15:45
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 igrishaev/6b54dc9665d44488a7f1e7d26ef98be3 to your computer and use it in GitHub Desktop.
Save igrishaev/6b54dc9665d44488a7f1e7d26ef98be3 to your computer and use it in GitHub Desktop.
(defn index-by
"Return a map where a key is (f item) and a value is item."
{:added "1.11"
:static true}
[f coll]
(persistent!
(reduce
(fn [ret x]
(assoc! ret (f x) x))
(transient {}) coll)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment