Created
January 15, 2014 16:38
-
-
Save methylene/8439568 to your computer and use it in GitHub Desktop.
clojure invert multi-valued map
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
(defn invert-map [m] | |
(reduce-kv | |
(fn [acc k v] | |
(merge-with (comp vec concat) | |
acc | |
(apply array-map (interleave v (repeat [k]))))) | |
{} m)) |
Author
methylene
commented
Jan 15, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment