%on% {funprog}R Documentation

Transform a binary function with a unary function

Description

Execute the binary function f on the results of applying unary function g to two arguments x and y.

Usage

f %on% g

Arguments

f

a binary function.

g

a unary function.

Details

Formally, %on% is defined this way : function(f, g) function(x, y) f(g(x), g(y)).

f can be a function taking two arguments but also a variadic function (i.e. whose first argument is ...), which will be fed with exactly two arguments.

A typical usage of this function is in combination with function like group_if.

Value

A binary function. This function transforms 2 inputs (with g) and combines the outputs (with f).

Examples

h <- max %on% abs
h(-2, 1)

[Package funprog version 0.3.0 Index]