Is there a way to remove items in a nested list by type such that (1 [2] 3 (4 [5] 6)) becomes (1 3 (4 6)) if I want to remove just the vectors?
Using postwalk, I can replace all vectors with nil, but I can not find a way to remove them.
(clojure.walk/postwalk
#(if (vector? %) nil %) '(1 [2] 3 (4 [5] 6)))
=>(1 nil 3 (4 nil 6))
Far from perfect but perhaps it is a good start:
(clojure.walk/prewalk #(if (list? %) (remove vector? %) %) '(1 [2] 3 (4 [5] 6)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With