Live data from Hacker News

R adds native pipe and lambda syntax

developer.r-project.org

11–20 of 150 posts

Re: R adds native pipe and lambda syntax

#12
post #4

Earlier quoted context omitted.

AFAIK the same as in Julia.

I think that symbol is used as an approximation of "lambda" character (λ) on a standard US keyboard.

Here is a tweet thread explaining this: https://twitter.com/rabaath/status/1335226691304775681?s=20

Re: R adds native pipe and lambda syntax

#13
post #3

Better late than never, but dplyr solved the pipe problem long time ago.

There is a big difference between what is allowed from within a package and what is possible in native implementation. As an example - currently this pipe operator seems to be implemented at the parser level. The parser simply takes the pipe expression and translates it into standard nested function call f(g(x)). Which means - there will be almost no cost in speed (%>% was notoriously slow). In addition the user will get the usual error stack in case something within this pipe fails.

Re: R adds native pipe and lambda syntax

#14
Kind of odd they didn't decide to go with the magrittr syntax, which is in common use and heavily promoted in dplyr / tidyverse.

I wonder if RStudio will change its `ctrl` + `shift` + m shortcut from the magrittr ( %>% ) style pipes to these new pipes ( |> )

Re: R adds native pipe and lambda syntax

#15
post #6

I'm sure some of us who are out of the loop might be wondering: what about the magrittr pipe operator (%>%) that we all know and love? Luke Tierney explains the move from %>% to a native pipe |> here [1]. The native pipe aims to be more efficient as well as addresses issues with the magrittr pipe like complex stack traces. Turns out the |> syntax is also used in Julia, Javascript and F#. The lambda syntax (\(x) -> x…

|> is also used in Elixir where it is implemented as a macro so it’s a little less flexible since it can’t be assigned as a value.

Re: R adds native pipe and lambda syntax

#16
post #6

I'm sure some of us who are out of the loop might be wondering: what about the magrittr pipe operator (%>%) that we all know and love? Luke Tierney explains the move from %>% to a native pipe |> here [1]. The native pipe aims to be more efficient as well as addresses issues with the magrittr pipe like complex stack traces. Turns out the |> syntax is also used in Julia, Javascript and F#. The lambda syntax (\(x) -> x…

Beautiful. - Elixir has this as well. Love it. - In Mathematica you'd have to write `data // f // g` to denote `g(f(data))`.

## Edit

Corrected a notation.

Re: R adds native pipe and lambda syntax

#17
post #4

Earlier quoted context omitted.

AFAIK the same as in Julia.

I think that symbol is used as an approximation of "lambda" character (λ) on a standard US keyboard.

It is, and it's not the first language to use it as such. But for many programmers it always triggers the 'escape' alarm in the mind, and it will always cause slight discomfort seeing it used in the raw.

Re: R adds native pipe and lambda syntax

#18
post #16
post #6

I'm sure some of us who are out of the loop might be wondering: what about the magrittr pipe operator (%>%) that we all know and love? Luke Tierney explains the move from %>% to a native pipe |> here [1]. The native pipe aims to be more efficient as well as addresses issues with the magrittr pipe like complex stack traces. Turns out the |> syntax is also used in Julia, Javascript and F#. The lambda syntax (\(x) -> x…

Beautiful. - Elixir has this as well. Love it. - In Mathematica you'd have to write `data // f // g` to denote `g(f(data))`. ## Edit Corrected a notation.

I don’t know Mathematica, but wouldn’t data // g // f make more sense for f(g(data)) ?

Re: R adds native pipe and lambda syntax

#19
post #16
post #6

I'm sure some of us who are out of the loop might be wondering: what about the magrittr pipe operator (%>%) that we all know and love? Luke Tierney explains the move from %>% to a native pipe |> here [1]. The native pipe aims to be more efficient as well as addresses issues with the magrittr pipe like complex stack traces. Turns out the |> syntax is also used in Julia, Javascript and F#. The lambda syntax (\(x) -> x…

Beautiful. - Elixir has this as well. Love it. - In Mathematica you'd have to write `data // f // g` to denote `g(f(data))`. ## Edit Corrected a notation.

if you use vscode this is an invaluable vscode snippet:

https://slickb.it/bits/70

Re: R adds native pipe and lambda syntax

#20
post #16

Earlier quoted context omitted.

Beautiful. - Elixir has this as well. Love it. - In Mathematica you'd have to write `data // f // g` to denote `g(f(data))`. ## Edit Corrected a notation.

I don’t know Mathematica, but wouldn’t data // g // f make more sense for f(g(data)) ?

You‘re right. That was I typo.
Post reply on HN