dgkf / R

An experimental reimagining of R
https://dgkf.github.io/R
GNU General Public License v3.0
136 stars 5 forks source link

How to treat vector-assignment to list #186

Open sebffischer opened 1 month ago

sebffischer commented 1 month ago

In R, assigining a vector to a list-slice vectorizes:

 l = list(1, 2, 3); l[1:2] = 10:11; l
#> [[1]]
#> [1] 10
#> 
#> [[2]]
#> [1] 11
#> 
#> [[3]]
#> [1] 3

Created on 2024-10-05 with reprex v2.1.1

I am not sure whether I think this is the desireable behavior. Maybe this should instead recycle the 10:11 into a list(10:11, 10:11) and then perform the assignment. This would then result in a list(10:11, 10:11, 3) instead of list(10, 11, 3) as above.