As @ZhekaKozlov noted, collections will be a problem because the type is the same regardless of the size of the collection.
For tuples, on the other hand, size is part of the type, so you can do something like this.
val f1 = (x: Int) => (x * 2, x * 3) //f1: Int => (Int, Int)
val f2 = ((x:Int) => f1(x)._1, (y:Int) => f1(y)._2) //f2: (Int => Int, Int => Int)
Not quite a “convenient” conversion, but doable.
source
share