Last active
January 2, 2016 03:49
-
-
Save brunoV/8246881 to your computer and use it in GitHub Desktop.
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
(defn mapmap [f m] | |
"Map over an associative array using a function on the values. Returns a | |
new map where the keys are the same as in the original but the values are | |
the result of applying f to the original values." | |
(reduce (fn [acc-map [k v]] (assoc acc-map k (f v))) {} m)) | |
(mapmap inc {:a 1 :b 2 :c 3}) => {:a 2 :b 3 :c 4} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment