|
|
|
|
|
by uryga
1731 days ago
|
|
y %>% f(x, ., z) === f(x, y, z)
R lets you do macro-ish things at at runtime [1], and `.` is a valid variable name [2]. so %>% can just evaluate the AST of its right argument in an environment with `. = a`.(it's probably a bit more involved because %>% also supports a %>% f(b) === f(a, b)
in which case %>% has to do some AST surgery to splice another argument in front of `b`.)--- [1] https://en.wikipedia.org/wiki/Fexpr [2] think `_` in python etc. R uses dots instead of underscores |
|