I have a list of lists in Scala as follows.
val inputList:List[List[Int]] = List(List(1, 2), List(3, 4, 5), List(1, 9))
I want a list of cross products of all the sub-lists.
val desiredOutput: List[List[Int]] = List(
List(1, 3, 1), List(1, 3, 9),
List(1, 4, 1), List(1, 4, 9),
List(1, 5, 1), List(1, 5, 9),
List(2, 3, 1), List(2, 3, 9),
List(2, 4, 1), List(2, 4, 9),
List(2, 5, 1), List(2, 5, 9))
The number of elements in inputList as well as the sublist are not fixed. What is the Scala way of doing this?