Created
November 4, 2010 15:28
-
-
Save bhenry/662618 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 lower-key [x] | |
(if (or (string? x) (keyword? x)) | |
(-> x name .toLowerCase keyword) | |
x)) | |
(defn map-keys | |
"applies f to each key of m. also to keys of m's vals and so on." | |
[f m] | |
(zipmap | |
(map (fn [k] | |
(f k)) | |
(keys m)) | |
(map (fn [v] | |
(if (map? v) | |
(map-keys f v) | |
v)) | |
(vals m)))) | |
(map-keys lower-key | |
{:aBaB 123 | |
"CAsasas" {1 "doesn't apply to non-string non-keyword keys" | |
:yoGURt "mmMMm" | |
:notVALUES "either"}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment