News for hackers. Stuff that matters.
Re:TC39 Pipeline Operator – Hack vs. F# by awild on Tuesday September 14, 2021 @05:17PM (#28531409)
Tidyr/dplyr (R) can do something very close to this but I don't know how it is achieved. There it is a dot
Re:TC39 Pipeline Operator – Hack vs. F# by uryga on Tuesday September 14, 2021 @05:34PM (#28531671)

  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