recursive_filter: Standard function operator.

View source: R/8_function_operators.R

recursive_filterR Documentation

Standard function operator.

Description

Standard function operator.

Usage

recursive_filter(f, x)

first(f, x)

last(f, x)

nth(f, x, n)

Arguments

f

A function that returns TRUE or FALSE.

x

A vector to be filtered.

n

The nth element desired. 1 means first.

Details

Filter any function.

Examples

library(functionalPlayground)

recursive_filter(is_even, 1:10)
recursive_filter(is_odd, 1:10)

first(is_even, 1:10)
first(is_odd, 1:10)

last(is_even, 1:10)
last(is_odd, 1:10)

nth(is_even, 1:10, 1) # same as first(is_even, 1:10)
nth(is_even, 1:10, 2) # second even element
nth(is_odd, 1:10, 3) # third odd element

gmcmacran/functional_playground documentation built on Aug. 5, 2024, 7:40 a.m.