Displaying 1 result from an estimated 1 matches for "inputvalue2".
Did you mean:
inputvalue1
2017 Nov 22
2
function pointers?
...copies of rnorm, but we really only need 1,
which we can use in the objects.
Thinking of this like C, I am looking to pass in a pointer to the
function. I found my way to the idea of putting a function in an
environment in order to pass it by reference:
rnormPointer <- function(inputValue1, inputValue2){
object <- new.env(parent=globalenv())
object$distr <- inputValue1
object$n <- inputValue2
class(object) <- 'pointer'
object
}
## Experiment with that
gg <- rnormPointer(rnorm, 33)
gg$distr(gg$n)
ptrList <- vector("list", N)
for(i in seq_al...