R.cache (version 0.14.0)

addMemoization: Creates a copy of an existing function such that its results are memoized

Description

Creates a copy of an existing function such that its results are memoized.

Usage

# S3 method for default
addMemoization(fcn, envir=parent.frame(), ...)

Arguments

fcn

A function (or the name of a function) that should be copied and have memoization added.

envir

The environment from where to look for the function.

...

Additional arguments for controlling the memoization, i.e. all arguments of memoizedCall() that are not passed to do.call().

Value

Returns a function.

Details

The new function is setup such that the the memoized call is done in the environment of the caller (the parent frame of the function).

If the function returns NULL, that particular function call is not memoized.

See Also

The returned function utilized memoizedCall() internally.