lapply <- function (X, FUN, ...) { FUN <- match.fun(FUN) ## internal code handles all vector types, including expressions ## However, it would be OK to have attributes which is.vector ## disallows. if(!is.vector(X) || is.object(X)) X <- as.list(X) .Internal(lapply(X, FUN)) } rapply <- function(object, f, classes = "ANY", deflt = NULL, how = c("unlist", "replace", "list"), ...) { if(typeof(object) != "list") stop("'object' must be a list") how <- match.arg(how) res <- .Internal(rapply(object, f, classes, deflt, how)) if(how == "unlist") unlist(res, recursive = TRUE) else res }