createMutator {FastUtils} | R Documentation |
Create a Mutator Function
Description
This function creates a mutator function based on a specified binary operator.
The output mutator function updates a variable in the parent frame by applying
the binary operator with a given value. It's recommended to use this function
to easily construct special functions in the form of %f%
where f
can be any
symbol of choice. See examples.
Usage
createMutator(binaryOperator)
Arguments
binaryOperator |
A binary operator function to apply for the mutation. |
Value
A function that takes a variable and a value, applying the binary operator to update the variable in the parent frame.
Examples
"%+=%" <- createMutator(add)
x <- 1
x %+=% 1
x # becomes 2
[Package FastUtils version 0.1.1 Index]