I don't think:
|
setMethod("lapply", "SimpleList", |
|
function(X, FUN, ...) lapply(as.list(X), match.fun(FUN), ...) |
|
) |
is needed, because base::lapply() does as.list(X) and match.fun(FUN) here;
> base::lapply
function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X))
X <- as.list(X)
.Internal(lapply(X, FUN))
}
<bytecode: 0x57e7ad744980>
<environment: namespace:base>
For example,
library(S4Vectors)
X <- SimpleList(a = letters, i = Rle(22:20, 4:2))
c(!is.vector(X), is.object(X))
#> [1] TRUE TRUE
class(as.list(X))
#> [1] "list"
y1 <- BiocGenerics::lapply(X, length)
y2 <- base::lapply(X, length)
identical(y1, y2)
#> [1] TRUE
I don't think:
S4Vectors/R/SimpleList-class.R
Lines 157 to 159 in cead68c
is needed, because
base::lapply()doesas.list(X)andmatch.fun(FUN)here;For example,