Last chance! 50% off unlimited learning
Sale ends in
make_fn_aware()
is a functional operator that enhances a function by
enabling it to interpret abbreviated functional arguments.
make_fn_aware(f, ...)
Function, or symbol or name of a function.
Name(s) of functional argument(s) of f
(strings) or NULL
.
Unsplicing of lists of strings is supported via !!!
.
A function with the same call signature as f
, but whose function
arguments, as designated by ...
, may be specified using an abbreviated
function expression of the form .(...)
, cf. as_fn()
. If ...
is empty
or NULL
, then f
is simply returned.
# NOT RUN {
reduce <- make_fn_aware(Reduce, "f")
## reduce() behaves just like Reduce()
Reduce(function(u, v) u + 1 / v, c(3, 7, 15, 1, 292), right = TRUE)
reduce(function(u, v) u + 1 / v, c(3, 7, 15, 1, 292), right = TRUE)
## reduce() can also interpret abbreviated function expressions
reduce(.(u, v ~ u + 1 / v), c(3, 7, 15, 1, 292), right = TRUE)
# }
Run the code above in your browser using DataLab