rush icon indicating copy to clipboard operation
rush copied to clipboard

How about pass parameters to functions using >> ?

Open J-F-Liu opened this issue 9 years ago • 2 comments

5 >> |x| x + 2 === 7
"-8" >> int & abs & |x| x / 2  >> sqrt === 2
("-8" >> int & abs, 2) >> |x, y| x + y >> z === 10
"1,2,3" >> split(",") & map(int & |x| x * 2) & join(",")

>> can be used to insert new arguments in the chain of process, assign value to the last variable. So it's operator precedence order is the same as equal sign.

J-F-Liu avatar Dec 21 '16 08:12 J-F-Liu

I'm not sure if there is an obvious place for it in the operator precedence order. And if there isn't, then it'd be common to use parentheses for disambiguation, which doesn't make it all that different from a regular function call.

Xion avatar Dec 21 '16 22:12 Xion

@Xion Updated my comment.

J-F-Liu avatar Dec 22 '16 01:12 J-F-Liu