Created
October 26, 2010 21:10
-
-
Save bmabey/647817 to your computer and use it in GitHub Desktop.
utils.clj
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 map-keys | |
"Renames each key of m to the value of generated by f when given the key" | |
[f m] | |
(persistent! | |
(reduce (fn [m [k v]] (assoc! m (f k) v)) (transient {}) m))) | |
The transient
version is faster since it isn't modifying the same persistent structure the entire time. http://clojure.org/transients
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what does the transient stuff bring to the table where this doesn't work?