Skip to content

Commit 9bd3ed4

Browse files
authored
Implement halve(Iterators.reverse(...)) (#60)
1 parent 48ffdec commit 9bd3ed4

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SplittablesBase.jl:
4242
* `Iterators.partition`
4343
* `Iterators.product`
4444
* `Iterators.enumerate`
45+
* `Iterators.reverse`
4546
* `skipmissing`
4647

4748
## Packages using SplittablesBase.jl

src/implementations.jl

+5
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ function halve(xs::Iterators.Enumerate)
270270
return enumerate(left), zip(length(left)+1:length(xs), right)
271271
end
272272

273+
function halve(xs::Iterators.Reverse)
274+
left, right = halve(xs.itr)
275+
return Iterators.reverse(right), Iterators.reverse(left)
276+
end
277+
273278
amount(xs::Base.SkipMissing) = amount(arguments(xs)[1])
274279

275280
function halve(xs::Base.SkipMissing)

test/test_halve.jl

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ zip("αβγ")
6060
zip(enumerate([11, 22, 33, 44]), 'a':'d')
6161
zip(enumerate([11, 22, 33, 44, 55]), 'a':'e')
6262
zip(Iterators.product(1:3, 'a':'b'), ones(3, 2))
63+
Iterators.reverse(1:10)
64+
Iterators.reverse(zip(1:3, 'a':'c'))
6365
skipmissing([1, 2, missing, 4])
6466
skipmissing([1, 2, missing, 4, 5])
6567
"""

0 commit comments

Comments
 (0)