, "" , , (.GlobalEnv, GlobalEnv as.environment(1)) , , .
- . , () . , , :
myFunction <- local({
cache <- list()
function(x,y,z){
indx = answerIndex(x,y,z)
if(indx %in% names(cacheList))
return(cacheList[indx])
[otherwise, do lots of calculations or data queries]
cahceList[indx] <<- answer
return(answer)
}
})
local , <<-, , , ( ) local() myFunction.