Displaying 1 result from an estimated 1 matches for "rnormpointer".
2017 Nov 22
2
function pointers?
..., n, mean, sd)
The storage holding 10000 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 <- vec...