parameterize view and make a parameterized version of using a function called pred
This commit is contained in:
parent
42befa556e
commit
c6046aa874
1 changed files with 16 additions and 1 deletions
|
|
@ -203,7 +203,12 @@
|
||||||
(assoc structure key (next-fn (get structure key)))
|
(assoc structure key (next-fn (get structure key)))
|
||||||
))
|
))
|
||||||
|
|
||||||
(defn view [afn] (i/->ViewPath afn))
|
(defparamspath view [afn]
|
||||||
|
(select* [this structure next-fn]
|
||||||
|
(next-fn (afn structure)))
|
||||||
|
(transform* [this structure next-fn]
|
||||||
|
(next-fn (afn structure))
|
||||||
|
))
|
||||||
|
|
||||||
(defn selected?
|
(defn selected?
|
||||||
"Filters the current value based on whether a selector finds anything.
|
"Filters the current value based on whether a selector finds anything.
|
||||||
|
|
@ -275,6 +280,16 @@
|
||||||
(transform* [aset structure next-fn]
|
(transform* [aset structure next-fn]
|
||||||
(i/filter-transform aset structure next-fn)))
|
(i/filter-transform aset structure next-fn)))
|
||||||
|
|
||||||
|
(defparamspath
|
||||||
|
^{:doc "Keeps the element only if it matches the supplied predicate. This is the
|
||||||
|
late-bound parameterized version of using a function directly in a path."}
|
||||||
|
pred
|
||||||
|
[afn]
|
||||||
|
(select* [this structure next-fn]
|
||||||
|
(i/filter-select afn structure next-fn))
|
||||||
|
(transform* [this structure next-fn]
|
||||||
|
(i/filter-transform afn structure next-fn)))
|
||||||
|
|
||||||
(defn collect [& path]
|
(defn collect [& path]
|
||||||
(pathed-collector [late path]
|
(pathed-collector [late path]
|
||||||
(collect-val [this structure]
|
(collect-val [this structure]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue