foreach icon indicating copy to clipboard operation
foreach copied to clipboard

Keep names in the output list

Open ntthung opened this issue 4 years ago • 0 comments

This is a feature request. It would be really nice to keep the names of the iterated list in the results. Here's an example.

xList <- list(a = 1, b = 2)
foreach(x = xList) %do% x^2

returns

[[1]]
[1] 1

[[2]]
[1] 4

but a named list similar to that returned by lapply() would be useful:

$a
[1] 1

$b
[1] 4

ntthung avatar Mar 06 '20 05:03 ntthung