Memoizing wrapper for lapply.

lapplym(X, FUN, ...)

Arguments

X

list or vector of inputs

FUN

function to apply

...

additional arguments passed to lapply

Value

list of results.

See also

Examples

fs <- function(x) { x <- x[[1]]; print(paste("see", x)); sin(x) } # should only print "see" twice, not 6 times lapplym(c(0, 1, 1, 0, 0, 1), fs)
#> [1] "see 0" #> [1] "see 1"
#> [[1]] #> [1] 0 #> #> [[2]] #> [1] 0.841471 #> #> [[3]] #> [1] 0.841471 #> #> [[4]] #> [1] 0 #> #> [[5]] #> [1] 0 #> #> [[6]] #> [1] 0.841471 #>