Add function transform-keys to clojure.walk

Description

In CLJ-1894 I proposed a patch to change clojure.walk/stringify-keys to include namespace if keywords use namespaces. I made a wrong assumption about backwards compatibility of that change, however I still think the behaviour is not exactly what it should be.

Interesting thing Alex Miller pointed out in his comment to CLJ-1894 is that stringify-keys and keywordize-keys are essentially the same function with a different transformation. I think having one function which does a deep transformation of map keys using a transformation supplied by user is a good idea and it could be used to simplify some Clojure libraries.

Proposal:

  • add clojure.walk/transform-keys to walk a map and transform all keys

  • use transform-keys in clojure.walk/stringify-keys & clojure.walk/keywordize-keys

Patch: clj1899-review1.patch

Screened by: Alex Miller

Environment

OS X, Java 8, Clojure 1.8

Activity

Show:
Raf Szałański
March 8, 2016, 12:37 PM

patch

Alex Miller
March 10, 2016, 3:20 PM

In the patch, transform-keys should take the arguments in the reverse order [m f] - generally for any function that is collection -> collection, the collection should be the first arg.

Raf Szałański
March 14, 2016, 3:34 PM

patch addressing issues pointed by Alex miller.

Assignee

Unassigned

Reporter

Raf Szałański

Labels

Approval

Prescreened

Patch

Code and Test

Affects versions

Priority

Major
Configure