Reputation: 1387
Is there any way to convert tuple into separate parameters and put them to function instead of binding to variables?
Something like
let nice funOf5 tupleOf5 =
funOf5 (Tuple.toParameters tupleOf5)
instead of
let ugly funOf5 tupleOf5 =
let (number1, number2, number3, number4, number5) = tupleOf5
funOf5 number1 number2 number3 number4 number5
Thanks.
Upvotes: 6
Views: 2016
Reputation: 25516
One solution, is to use pattern matching in the function definition.
This is inspired by the std lib solution for |||>
which is
let inline (|||>) (x1,x2,x3) f = f x1 x2 x3
then you can have
let inline funof5 (x1,x2,x3,x4,x5) f = f x1 x2 x3 x4 x5
Upvotes: 9