idropwhile: Iterator that drops elements until the predicate function...

Description Usage Arguments Details Value Examples

Description

Constructs an iterator that drops elements from the iterable object as long as the predicate function is true; afterwards, every element of iterable object is returned.

Usage

1
idropwhile(predicate, object)

Arguments

predicate

a function that determines whether an element is TRUE or FALSE. The function is assumed to take only one argument.

object

an iterable object

Details

Because the iterator does not return any elements until the predicate first becomes false, there may have a lengthy start-up time before elements are returned.

Value

iterator object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Filters out numbers exceeding 3
not_too_large <- function(x) {
  x <= 3
}
it <- idropwhile(not_too_large, 1:8)
as.list(it)

# Same approach but uses an anonymous function
it2 <- idropwhile(function(x) x <= 10, seq(2, 20, by=2))
as.list(it2)

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