Is it possible to write a function to accept a tuple of variable length? I’m trying to write a method that can be called like this:
let a = sum(1,2)
let b = sum(1,2,3)
EDIT: Could it be interpreted as a function call with params? Or would the method need to be written in c#:
double sum(params object[] double) {
...
}
No – tuples are by definition not variable length, and to write a function like this you’d need something like template metaprogramming in C++ – and there isn’t such a thing in F#;
let inlinewon’t help you there either.Of course, if you take a list instead, it won’t look that much different: