product method

List<List<T>> product(
  1. int repeat
)

Returns all the Cartesian product of a list.

Specify the number of repetitions as the argument. If specified the argument under the 0, returns the empty list of a list.

[1, 2, 3].product(2);
[[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]
[1, 2, 3].product(-1);
[[]]

Implementation

List<List<T>> product(int repeat) {
  return _product([...this], repeat);
}