iroundrobin: Iterator that traverses each given iterable in a roundrobin...

Description Usage Arguments Value Examples

Description

Constructs an iterator that traverses each given iterable in a roundrobin order. That is, the iterables are traversed in an alternating fashion such that the each element is drawn from the next iterable. If an iterable has no more available elements, it is skipped, and the next element is taken from the next iterable having available elements.

Usage

1

Arguments

...

multiple arguments to iterate through in roundrobin sequence

Value

iterator that alternates through each argument in roundrobin sequence

Examples

1
2
3
4
5
6
7
it <- iterators::iter(c("A", "B", "C"))
it2 <- iterators::iter("D")
it3 <- iterators::iter(c("E", "F"))
as.list(iroundrobin(it, it2, it3)) # A D E B F C

it_rr <- iroundrobin(1:3, 4:5, 7:10)
as.list(it_rr) # 1 4 7 2 5 8 3 9 10

Example output

[[1]]
[1] "A"

[[2]]
[1] "D"

[[3]]
[1] "E"

[[4]]
[1] "B"

[[5]]
[1] "F"

[[6]]
[1] "C"

[[1]]
[1] 1

[[2]]
[1] 4

[[3]]
[1] 7

[[4]]
[1] 2

[[5]]
[1] 5

[[6]]
[1] 8

[[7]]
[1] 3

[[8]]
[1] 9

[[9]]
[1] 10

itertools2 documentation built on May 2, 2019, 3:37 p.m.