To achieve a friendly syntax for operators with parameters, we use a pattern where the library provides a function-that-returns-a-function.
> seq.map
[Function]
> seq.map(x => x * 2)
[Function]
We do not do this for operators without parameters.
Some operators have parameters, but each has a default value:
> seq.unique
[Function]
> seq.unique()
[Function]
This makes operator usage somewhat inconsistent:
[ 1, 2, 3 ]
|> map(x => x * 2) // Parentheses to wrap parameters
|> unique() // Parentheses required because we have default arguments
|> toArray; // No parentheses, because this is not a function-that-returns-a-function
Perhaps it should look like this instead?
[ 1, 2, 3 ]
|> map(x => x * 2)
|> unique()
|> toArray(); // Parentheses required for all operators
To achieve a friendly syntax for operators with parameters, we use a pattern where the library provides a function-that-returns-a-function.
We do not do this for operators without parameters.
Some operators have parameters, but each has a default value:
This makes operator usage somewhat inconsistent:
Perhaps it should look like this instead?