cartesianProduct<T> static method
Computes the Cartesian product of a list of lists.
lists
: A list of lists containing elements of typeT
.
Returns: An iterable containing lists representing the Cartesian product.
Implementation
static Iterable<List<T>> cartesianProduct<T>(List<List<T>> lists) {
return lists.fold(<List<T>>[[]],
(result, list) => result.expand((x) => list.map((y) => [...x, y])));
}