combs method

List<List<T>> combs(
  1. int n
)

Returns the combinations of K distinct lists selected from the N elements of a list.

[1, 2, 3, 4, 5].combs(3);
[[1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 3, 4], [1, 3, 5], [1, 4, 5], [2, 3, 4], [2, 3, 5], [2, 4, 5], [3, 4, 5]]
[1, 2, 3, 4, 5].combs(5);
[[1, 2, 3, 4, 5]]

Implementation

List<List<T>> combs(int n) {
  return _combs(n, [...this]);
}