#' @tags future_apply
#' @tags globals
#' @tags detritus-files
#' @tags sequential multisession multicore
if (packageVersion("future") > "1.49.0" && isTRUE(getOption("future.globals.keepWhere"))) {
library(future.apply)
options(future.debug = FALSE)
foo <- function(..., FUN = function(...) list(...)) {
args <- list(...)
future_lapply(1L, FUN = function(x) {
do.call(FUN, args = c(list(x), args))
})
}
bar <- function(..., fun = function(...) list(...)) {
future_lapply(1L, FUN = function(x) fun(x, ...))
}
yaa <- function(..., FUN = function(...) list(...)) {
future_lapply(1L, FUN = function(x) {
do.call(FUN, args = c(list(x), ...))
})
}
for (strategy in supportedStrategies()) {
message(sprintf("- plan('%s') ...", strategy))
plan(strategy)
x1 <- foo()
y1 <- bar()
stopifnot(identical(y1, x1))
z1 <- yaa()
stopifnot(identical(z1, x1))
x2 <- foo(a = 2)
y2 <- bar(a = 2)
z2 <- yaa(a = 2)
stopifnot(identical(y2, x2))
stopifnot(identical(z2, x2))
message(sprintf("- plan('%s') ... done", strategy))
}
} ## if (packageVersion("future") > ...)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.