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(rlang)
library(purrr)
x <- expr(foo(a, b, 10))
modify(x, ~ if (is.numeric(.x)) .x + 10 else .x)
We should probably expand the vector definition to include pairlists (this will require custom code but it's probably worth it as the connections between purrr and rlang become stronger)
For map(), this will require a different approach to map_impl() + call_loop() which currently generates calls of the form f(x[[i]]) modifying the value of i in an environment. Instead will need to generate __x_i by looping over the pairlist. For efficiently, will also need to name output as we go using the TAG().
May also be worth a custom modify() method because replacement with [[<- is unlikely to be efficient.
In the short term, might be better to just coerce back and forth to a list, not worrying about efficiency.
Activity
hadley commentedon Nov 20, 2017
For
map(), this will require a different approach tomap_impl()+call_loop()which currently generates calls of the formf(x[[i]])modifying the value ofiin an environment. Instead will need to generate__x_iby looping over the pairlist. For efficiently, will also need to name output as we go using theTAG().May also be worth a custom
modify()method because replacement with[[<-is unlikely to be efficient.In the short term, might be better to just coerce back and forth to a list, not worrying about efficiency.
hadley commentedon Nov 20, 2017
Actually we can just rely on the fact that
[[has an existing implementationSupport calls and pairlists in map & modify