discard: Filter a series by discarding results that fulfill a...

Description Usage Arguments Examples

View source: R/filter.R

Description

Filter a series by discarding results that fulfill a predicate

Usage

1
discard(.generator, .drop)

Arguments

.generator

A function with the class generator

.drop

A predicate function, returning TRUE or FALSE

Examples

1
2
3
4
5
6
7
# Generate even numbers
counter <- generator(0, ~ state + 1)
counter %>% discard(~ state %% 2 == 0) %>% take(5)

# Combine a wrap and a counter
squares <- function(state) state ^ 2
counter %>% wrap(squares) %>% discard(~ state %% 3 == 0) %>% take(5)

michaelquinn32/generators documentation built on May 22, 2019, 9:52 p.m.