Test for all, any or none

if_all(.l, .p = isTRUE, .f)

if_any(.l, .p = isTRUE, .f)

if_none(.l, .p = isTRUE, .f)

Arguments

.l

the list to test.

.p

the predicate for testing. Defaut is isTRUE.

.f

a mapper or a function run if .p(.x) is TRUE.

Value

If .p(.x) is TRUE, .f() is run.

Examples

if_all(1:10, ~ .x < 11, ~ return(letters[1:10]))
#>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
if_any(1:10, is.numeric, ~ return(letters[1:10]))
#>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
if_none(1:10, is.numeric, ~ return(letters[1:10]))