finding: Find first item that matches certain conditions

Description Usage Arguments Value Examples

Description

The argument names here are meant to follow purrr::detect.

Usage

1
2
3
4
5
find_value2(.x, .y, .p, ..., .dir = c("forward", "backward"), .default = NULL)

find_value(.x, .p, ..., .dir = c("forward", "backward"), .default = NULL)

find_position(.x, .p, ..., .dir = c("forward", "backward"), .default = NULL)

Arguments

.x, .y

Vectors to iterate over. For 2-argument version, .x, .y must have the same length.

.p

A predicate function for determining matches.

...

Additional arguments to set for the predicate

.dir

Direction to traverse the items. One of "forward" (default) or "backward".

.default

Value used when no match is found.

Value

either the .default value or the values of the first match.

Examples

1
2
3
find_value2(1:10, -4:5, function(x, y) x + y > 10)
find_value2(1:10, -4:5, function(x, y) x + y > 11)
find_value2(1:10, -4:5, function(x, y) x + y > 100)

tjmahr/adventofcode20 documentation built on Dec. 31, 2020, 8:39 a.m.