reimplement walker in terms of recursive-path to support NONE removal

This commit is contained in:
nathanmarz 2017-06-01 01:38:12 -04:00
parent e8f15c4137
commit 340d6d3065
2 changed files with 13 additions and 12 deletions

View file

@ -10,7 +10,8 @@
defdynamicnav
dynamicnav
richnav
defrichnav]]
defrichnav
recursive-path]]
[com.rpl.specter.util-macros :refer
[doseqres]]))
@ -826,16 +827,6 @@
(merge (reduce dissoc structure m-keys)
newmap))))
(defnav
^{:doc "Using clojure.walk, navigate the data structure until reaching
a value for which `afn` returns truthy."}
walker
[afn]
(select* [this structure next-fn]
(i/walk-select afn next-fn structure))
(transform* [this structure next-fn]
(i/walk-until afn next-fn structure)))
(defnav
^{:doc "Like `walker` but maintains metadata of any forms traversed."}
codewalker
@ -1285,3 +1276,13 @@
to implement post-order traversal."
[& path]
(multi-path path STAY))
(def
^{:doc "Navigate the data structure until reaching
a value for which `afn` returns truthy. Has
same semantics as clojure.walk."}
walker
(recursive-path [apred] p
(cond-path (pred apred) STAY
coll? [ALL p]
)))

View file

@ -129,7 +129,7 @@
(all-transform [structure next-fn]
(non-transient-map-all-transform structure next-fn (empty structure)))
clojure.lang.IRecord
#?(:clj clojure.lang.IRecord :cljs cljs.core/IRecord)
(all-transform [structure next-fn]
(reduce
(fn [res kv] (conj res (next-fn kv)))