restrict_environment: Build a new function with a smaller environment
Description
As standard feature, R include in the environment of a function
all the variables that are available when the function is created.
This, however is prompt to leak reference when you have a factory
of function and they are created within a list.. it will include all
the component of the list in the function environment.
To prevent that, the random generator functions are encapsulated with a
restricted environment where only the variables that the function requires
to work are included
Usage
restrict_environment(f, ...)
Value
new function with a restricted environment
Arguments
f
input function
...
define the set of variables to be included as variable = value.