change FIRST/LAST to select nothing on empty sequences, closes #4
This commit is contained in:
parent
7d3c0ca7cb
commit
bcc15b1587
3 changed files with 13 additions and 15 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
## 0.5.6
|
||||||
|
* Add multi-path implementation
|
||||||
|
* change FIRST/LAST to select nothing on an empty sequence
|
||||||
|
|
||||||
## 0.5.5
|
## 0.5.5
|
||||||
* Change filterer to accept a selector (that acts like selected? to determine whether or not to select value)
|
* Change filterer to accept a selector (that acts like selected? to determine whether or not to select value)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,9 +113,9 @@
|
||||||
|
|
||||||
(def VAL (->ValCollect))
|
(def VAL (->ValCollect))
|
||||||
|
|
||||||
(def LAST (->LastStructurePath))
|
(def LAST (->PosStructurePath last set-last))
|
||||||
|
|
||||||
(def FIRST (->FirstStructurePath))
|
(def FIRST (->PosStructurePath first set-first))
|
||||||
|
|
||||||
(defn srange-dynamic [start-fn end-fn] (->SRangePath start-fn end-fn))
|
(defn srange-dynamic [start-fn end-fn] (->SRangePath start-fn end-fn))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -374,23 +374,17 @@
|
||||||
(collect-val [this structure]
|
(collect-val [this structure]
|
||||||
structure))
|
structure))
|
||||||
|
|
||||||
(deftype LastStructurePath [])
|
(deftype PosStructurePath [getter setter])
|
||||||
|
|
||||||
(extend-protocol StructurePath
|
(extend-protocol StructurePath
|
||||||
LastStructurePath
|
PosStructurePath
|
||||||
(select* [this structure next-fn]
|
(select* [this structure next-fn]
|
||||||
(next-fn (last structure)))
|
(if-not (empty? structure)
|
||||||
|
(next-fn ((.getter this) structure))))
|
||||||
(transform* [this structure next-fn]
|
(transform* [this structure next-fn]
|
||||||
(set-last structure (next-fn (last structure)))))
|
(if (empty? structure)
|
||||||
|
structure
|
||||||
(deftype FirstStructurePath [])
|
((.setter this) structure (next-fn ((.getter this) structure))))))
|
||||||
|
|
||||||
(extend-protocol StructurePath
|
|
||||||
FirstStructurePath
|
|
||||||
(select* [this structure next-fn]
|
|
||||||
(next-fn (first structure)))
|
|
||||||
(transform* [this structure next-fn]
|
|
||||||
(set-first structure (next-fn (first structure)))))
|
|
||||||
|
|
||||||
(deftype WalkerStructurePath [afn])
|
(deftype WalkerStructurePath [afn])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue