Learn R Programming

iterors (version 1.0)

consume: Consumes the first n elements of an iterator

Description

Advances the iterator n-steps ahead without returning anything.

Usage

consume(obj, n = Inf, ...)

# S3 method for iteror consume(obj, n = Inf, ...)

Value

obj, invisibly.

Arguments

obj

an iterable object

n

The number of elements to consume.

...

passed along to iteror constructor.

See Also

take collect

Examples

Run this code
it <- iteror(1:10)
# Skips the first 5 elements
consume(it, n=5)
# Returns 6
nextOr(it, NA)

it2 <- iteror(letters)
# Skips the first 4 elements
consume(it2, 4)
# Returns 'e'
nextOr(it2, NA)

Run the code above in your browser using DataLab