Skip to content

lapply() for SimpleList not needed(?) #132

@HenrikBengtsson

Description

@HenrikBengtsson

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions