Skip to content

Instantly share code, notes, and snippets.

@brunoV
Last active January 2, 2016 03:49
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 brunoV/8246881 to your computer and use it in GitHub Desktop.
Save brunoV/8246881 to your computer and use it in GitHub Desktop.
(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