I have two lists:
val l1 = List(1,2,3)
val l2 = List(1,2,4,5)
Combining these two lists, how do I obtain the following result?
List((1,1), (1,2), (1,4), (1,5), (2,2), (2,4), (2,5), (3,1), (3,2), (3,4), (3,5))
Note how only one of (2,1) or (1,2) is chosen. Order of the pairs doesn't matter. How do I compute the output efficiently given that the two input lists are large.
Thanks in advance.