v0.8.3: fix #10 (and another bug in padded partition) and update doc
This commit is contained in:
parent
d5e5aa3670
commit
8a9d383198
4 changed files with 14 additions and 8 deletions
|
|
@ -21,7 +21,7 @@ Transducing contexts: `transjuxt` (for performing several transductions in a sin
|
|||
Add this dependency to your project:
|
||||
|
||||
```clj
|
||||
[net.cgrand/xforms "0.8.2"]
|
||||
[net.cgrand/xforms "0.8.3"]
|
||||
```
|
||||
|
||||
```clj
|
||||
|
|
@ -127,16 +127,16 @@ It's worth noting that all transformed outputs are subsequently interleaved. See
|
|||
|
||||
```clj
|
||||
=> (sequence (x/partition 2 1 identity) (range 8))
|
||||
(0 1 1 2 2 3 3 4 4 5 5 6 6 7 7)
|
||||
(0 1 1 2 2 3 3 4 4 5 5 6 6 7)
|
||||
=> (sequence (x/by-key odd? identity) (range 8))
|
||||
([false 0] [true 1] [false 2] [true 3] [false 4] [true 5] [false 6] [true 7])
|
||||
```
|
||||
|
||||
That's why most of the time the last stage of the sub-transducer will be a `x/reduce` or a `x/into`:
|
||||
That's why most of the time the last stage of the sub-transducer will be a 1-item transducer like `x/reduce` or `x/into`:
|
||||
|
||||
```clj
|
||||
=> (sequence (x/partition 2 1 (x/into [])) (range 8))
|
||||
([0 1] [1 2] [2 3] [3 4] [4 5] [5 6] [6 7] [7])
|
||||
([0 1] [1 2] [2 3] [3 4] [4 5] [5 6] [6 7])
|
||||
=> (sequence (x/by-key odd? (x/into [])) (range 8))
|
||||
([false [0 2 4 6]] [true [1 3 5 7]])
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
(defproject net.cgrand/xforms "0.8.2"
|
||||
(defproject net.cgrand/xforms "0.8.3"
|
||||
:description "Extra transducers for Clojure"
|
||||
:url "https://github.com/cgrand/xforms"
|
||||
:license {:name "Eclipse Public License"
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@
|
|||
(let [xform (comp cat (take n) xform)
|
||||
; don't use mxrf for completion: we want completion and don't want reduced-wrapping
|
||||
acc (transduce xform rf acc [(.getValues dq) pad])]
|
||||
(vreset! @barrier n)
|
||||
(vreset! barrier n)
|
||||
(.clear dq)
|
||||
acc)
|
||||
acc))
|
||||
|
|
@ -330,8 +330,8 @@
|
|||
(when (< b n) (.add dq (if (nil? x) dq x)))
|
||||
(if (zero? b)
|
||||
; this transduce may return a reduced because of mxrf wrapping reduceds coming from rf
|
||||
(let [acc (transduce xform mxrf acc (.getValues dq))]
|
||||
(dotimes [_ (min n step)] (.poll dq))
|
||||
(let [acc (core/transduce xform mxrf acc (.getValues dq))]
|
||||
(dotimes [_ (core/min n step)] (.poll dq))
|
||||
(vswap! barrier + step)
|
||||
acc)
|
||||
acc)))))))))
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@
|
|||
(is (= (into [] (comp (take 3) (x/reductions +)) (range)) [0 0 1 3]))
|
||||
(is (= (into [] (x/reductions (constantly (reduced 42)) 0) (range)) [0 42])))
|
||||
|
||||
(deftest partition
|
||||
(is (= (into [] (x/partition 2 1 nil (x/into [])) (range 8))
|
||||
[[0 1] [1 2] [2 3] [3 4] [4 5] [5 6] [6 7] [7]]))
|
||||
(is (= (into [] (x/partition 2 1 (x/into [])) (range 8))
|
||||
[[0 1] [1 2] [2 3] [3 4] [4 5] [5 6] [6 7]])))
|
||||
|
||||
#?(:clj
|
||||
(deftest window-by-time
|
||||
(is (= (into
|
||||
|
|
|
|||
Loading…
Reference in a new issue