0

I can walk the top-level of the following map using walk in Clojure:

(use 'clojure.walk)
(walk (fn [[k v]] (println (type k) k v)) identity {:a 1 :b {:c 3}})

Result:

clojure.lang.Keyword :b {:c 3}
clojure.lang.Keyword :a 1
{}

(This works in a very similar way to map)

But when I use postwalk - it blows up trying to do destructuring:

(postwalk (fn [[k v]] (println (type k) k v)) {:a 1 :b {:c 3}})

Result:

UnsupportedOperationException nth not supported on this type: Keyword  clojure.lang.RT.nthFrom (RT.java:857)
hawkeye
  • 34,745
  • 30
  • 150
  • 304

1 Answers1

1

Maybe looking at what happens when you postwalk can shed some light into your issues.

user=> (postwalk println {:a 1 :b {:c 3}})
:a
1
[nil nil]
:b
:c
3
[nil nil]
{}
[nil nil]
{}
nil
user=> 
dsm
  • 10,263
  • 1
  • 38
  • 72