Displaying 1 result from an estimated 1 matches for "mkfact".
Did you mean:
fact
1999 Jun 15
1
Accessing a function's environment
...ow the name
under which the function will be stored so you can't use something
like environment(Fact). Just as "Recall" means to call myself again
regardless of the name, is there a way of a function getting the
environment in which it was defined without knowing its own name?
> mkFact # a function that constructs a factorial function
function ()
{
.env <- environment()
function(n) {
nm <- paste(".", n, sep = "/")
if (n <= 0)
return(1)
if (exists(nm, envir = .env))
return(get(nm, envir = .env))
ans <- n * R...