6 ms·
I'm sad that R didn't go closer to JavaScript style for Lambda instead of going toward Haskell, e.g., ‘\(x) x + 1’ vs x=> x+1
by abirch 4y ago
I'm sad that R didn't go closer to JavaScript style for Lambda instead of going toward Haskell, e.g., ‘\(x) x + 1’ vs x=> x+1
- bruce343434 4y agoWhat's sad about it?
- reitanqild 4y agoJS version is more readable for most people. (I'm no big fan of JS in general, unless it is TS but I consider that a different language.)
- abirch 4y agoExactly and it could bring R to a larger audience.
- tomlue 4y agoI prefer the R formula syntax. i.e ~ . + 1 ~ .x + .y
- tfehring 4y agoI like this syntax better than the new lambda syntax, but I think it's good that a proper lambda syntax exists now. Not all higher-order functions accept formulas (they have to wrap their function arguments with rlang::as_function or equivalent), and there are probably some obscure cases where the distinction between a formula and a function matters.
- wodenokoto 4y agoI've always liked that lambda and functions are the same thing in R and write `function(x){x + 1}` I dislike both of your examples and am glad to have never seen that in any R code I've met.
- abirch 4y agoit's new as of R 4.1 along with the new pipe operator https://www.r-bloggers.com/2021/05/the-new-r-pipe/ https://www.r-bloggers.com/2021/05/the-new-r-pipe/