tidyverse / purrr

A functional programming toolkit for R
https://purrr.tidyverse.org/
Other
1.28k stars 272 forks source link

`zap()` and `modify_at` #1005

Closed hadley closed 1 year ago

hadley commented 2 years ago
library(purrr)
x3 <- list(a = 1, b = 2)
x3 |> 
  modify_at("b", \(x) zap()) |> 
  str()
#> List of 2
#>  $ a: num 1
#>  $ b: list()
#>   ..- attr(*, "class")= chr "rlang_zap"

Created on 2022-11-15 with reprex v2.0.2 should error?

hadley commented 2 years ago

Error should say something about length preserving invariant.