make_fn_aware: Make a function aware of abbreviated functional arguments

View source: R/make-fn-aware.R

make_fn_awareR Documentation

Make a function aware of abbreviated functional arguments

Description

make_fn_aware() is a functional operator that enhances a function by enabling it to interpret abbreviated functional arguments.

Usage

make_fn_aware(f, ...)

Arguments

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 !!!.

Value

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.

See Also

as_fn()

Examples

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)


egnha/nofrills documentation built on March 23, 2022, 9:03 p.m.