actulab-2014-solution-coope.../mcsapply.R
François Pelletier 6c108afe25 solution originale
2014-06-02 19:49:28 -04:00

12 lines
369 B
R

require("multicore")
mcsapply <- function (X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
{
FUN <- match.fun(FUN)
answer <- mclapply(X = X, FUN = FUN, ...)
if (USE.NAMES && is.character(X) && is.null(names(answer)))
names(answer) <- X
if (!identical(simplify, FALSE) && length(answer))
simplify2array(answer, higher = (simplify == "array"))
else answer
}