Welcome! Please see the About page for a little more info on how this works.

0 votes
in Collections by
closed by

It's simple. Just like that:

> clojure.walk/walk:
(outer (reduce (fn [r x] (conj r (inner x))) form form))
=> (outer (into form (map inner) form))
(outer (into (empty form) (map inner form)))
=> (outer (into (empty form) (map inner) form))
> clojure.walk/keywordize-keys:
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)
=> (postwalk (fn [x] (if (map? x) (into {} (map f) x) x)) m)
> clojure.walk/strigify-keys:
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)
=> (postwalk (fn [x] (if (map? x) (into {} (map f) x) x)) m)
by
I even think this should be replaced with `reduce-kv` in `keywordize-keys` and `stringify-keys`:

    (let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))]
      ;; only apply to maps
      (postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m))
...