ipad {itertools2} | R Documentation |
Iterator that returns an object followed indefinitely by a fill value
Description
Constructs an iterator that returns an iterable object
before padding
the iterator with the given fill
value indefinitely.
Usage
ipad(object, fill = NA)
Arguments
object |
an iterable object |
fill |
the value to pad the indefinite iterator after the initial
|
Value
iterator that returns object
followed indefinitely by the
fill
value
Examples
it <- iterators::iter(1:9)
it_ipad <- ipad(it)
as.list(islice(it_ipad, end=9)) # Same as as.list(1:9)
it2 <- iterators::iter(1:9)
it2_ipad <- ipad(it2)
as.list(islice(it2_ipad, end=10)) # Same as as.list(c(1:9, NA))
it3 <- iterators::iter(1:9)
it3_ipad <- ipad(it3, fill=TRUE)
as.list(islice(it3_ipad, end=10)) # Same as as.list(c(1:9, TRUE))
[Package itertools2 version 0.1.1 Index]