Guest User

Untitled

a guest
Jun 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. (defn lower-key [x]
  2. (if (or (string? x) (keyword? x))
  3. (-> x name .toLowerCase keyword)
  4. x))
  5.  
  6.  
  7. (defn map-keys
  8. "applies f to each key of m. also to keys of m's vals and so on."
  9. [f m]
  10. (zipmap
  11. (map (fn [k]
  12. (f k))
  13. (keys m))
  14. (map (fn [v]
  15. (if (map? v)
  16. (map-keys f v)
  17. v))
  18. (vals m))))
  19.  
  20. (map-keys lower-key
  21. {:aBaB 123
  22. "CAsasas" {1 "doesn't apply to non-string non-keyword keys"
  23. :yoGURt "mmMMm"
  24. :notVALUES "either"}})
Add Comment
Please, Sign In to add comment