Skip to content

Instantly share code, notes, and snippets.

@bdesham
Created June 13, 2011 21:47
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 bdesham/1023802 to your computer and use it in GitHub Desktop.
Save bdesham/1023802 to your computer and use it in GitHub Desktop.
Calling a function on the values in a map
(defn modify-vals
[f m]
(zipmap
(keys m)
(for [item (vals m)] (f item))))
@bdesham
Copy link
Author

bdesham commented Jun 13, 2011

Better:

(defn modify-vals [f m]
  (into {} (for [[k v] m] [k (f v)])))

Thanks to amalloy in #clojure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment