You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(fuj)
lst<-function(...) {
e<- as.list(substitute(list(...)))[-1L]
lapply(e[!vapply(e, identical, NA, substitute(), USE.NAMES=FALSE)], eval)
}
# list0() doesn't do well with a few edge bases
try(list0())
#> Warning in seq_len(i - off): first element used of 'length.out' argument#> Error in seq_len(i - off) : #> argument must be coercible to non-negative integer
try(list0(b= , ))
#> Error in names(out) <- names(mc)[-1L][seq_len(i - off)] : #> 'names' attribute [1] must be the same length as the vector [0]
try(list0(a=1, , ))
#> Error in names(out) <- names(mc)[-1L][seq_len(i - off)] : #> 'names' attribute [2] must be the same length as the vector [1]# newer implementation doesn't have these issues
lst()
#> list()
lst(b= , )
#> named list()
lst(a=1, , )
#> $a#> [1] 1# and it's fasterfoo<-"hello"bench::mark(
list0= list0(a=1, b=2, , 3, foo, list),
lst= lst(a=1, b=2, , 3, foo, list, b= , )
)
#> # A tibble: 2 × 6#> expression min median `itr/sec` mem_alloc `gc/sec`#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>#> 1 list0 270µs 299µs 2439. 0B 2.07#> 2 lst 124µs 130µs 6912. 0B 4.12
Created on 2024-02-15 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: