diff --git a/src/com/rpl/specter.cljc b/src/com/rpl/specter.cljc index 3d9f390..c13c26f 100644 --- a/src/com/rpl/specter.cljc +++ b/src/com/rpl/specter.cljc @@ -203,7 +203,12 @@ (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? "Filters the current value based on whether a selector finds anything. @@ -275,6 +280,16 @@ (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] (pathed-collector [late path] (collect-val [this structure]