cartesianProduct

fun <T> List<List<T>>.cartesianProduct(): List<List<T>>

Returns the cartesian product between each list in this (i.e. every possible list formed by choosing an element from each of the sublists where order matters). Elements in each sub-list must have homogeneous elements.

e.g. this = [A, B, C, D, X, Y] => [A, C, X, A, C, Y, A, D, X, A, D, Y, B, C, X, B, C, Y, B, D, X, B, D, Y]