Learn R Programming

iterors (version 1.0)

i_pad: 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

i_pad(object, fill = NA, ...)

Value

iterator that returns object followed indefinitely by the fill value

Arguments

object

an iterable object

fill

the value to pad the indefinite iterator after the initial object is consumed. Default: NA

...

Passed along to iteror constructor.

Examples

Run this code

it <- iteror(1:9)
it_i_pad <- i_pad(it)
as.list(i_slice(it_i_pad, end=9)) # Same as as.list(1:9)

it2 <- iteror(1:9)
it2_i_pad <- i_pad(it2)
as.list(i_slice(it2_i_pad, end=10)) # Same as as.list(c(1:9, NA))

it3 <- iteror(1:9)
it3_i_pad <- i_pad(it3, fill=TRUE)
as.list(i_slice(it3_i_pad, end=10)) # Same as as.list(c(1:9, TRUE))

Run the code above in your browser using DataLab