Last active
December 11, 2015 22:18
-
-
Save nathanic/4668048 to your computer and use it in GitHub Desktop.
Clojure version of something josh was trying in Guava
This file contains 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
(def input [["a" "apple"] ["a" "amazon"] ["b" "banana"] ["c" "clown"]]) | |
(->> (group-by first input) ; now we have our keys pointing to lists of every key value pair with that key | |
(map (fn [[k v]] [k (map second v)])) ; for each key value pair, keep only the second parts of the values | |
(into {})) ; throw it into a hash map | |
;=> {"a" ("apple" "amazon"), "b" ("banana"), "c" ("clown")} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment