How can I (if at all) emulate variable functions (not methods) so that I can write
sum 1 2 3 sum 1 2 3 4 5 sum 1 2 3 4 5 6 7
The code above only means an example - obviously, if I had to list, and then
[ 1; 2 ; 3] |> List.sum
is a much better way.
However, I am looking for a structurally similar solution , for example this is a Haskell solution
It is also important that the normal syntax for function calls and parameter values ββremains unchanged. So
sum 1 2 3
against
sum(1, 2, 3)
which actually means that
let sum ([<ParamArray>] arr) = ...
not required in this particular case.
The motivation for all this: I am studying the external boundaries of the system and syntax such as F #. And I am fully aware that I may have crossed the line of what is already possible.
PS: my specific ideas (which I did not describe here) can also be solved in a completely different way - so I know, and therefore I already did it. So my question is not this: how can this be solved differently, but how can this be solved structurally, like Haskell.
PPS: Double Karma-Points, if you can make the whole solution recursive.
f # variadic-functions
robkuz
source share