%fn% {matchr} | R Documentation |
Syntactic sugar for creating a single-variable function. Can be conveniently used in Match
statements.
lhs %fn% rhs
lhs |
symbol used to denote the function argument |
rhs |
expression that is converted to the function body. |
a function
Match(
"abc",
is.numeric -> -1,
i %fn% grepl("bc", i) -> 0,
is.character -> 1
)
print_sq_log <- i %fn% print(sqrt(log(i)))
print_sq_log(10)