Type of elements in the iterable
Optionalk: number
Optional size of each combination (defaults to the length of the input, i.e. a single combination of all elements)
A function that takes an iterable and returns a generator of combinations
// Generate all 2-element combinations
const pairs = [...combinations(2)([1, 2, 3, 4])]
// Result: [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]
Creates a generator that yields all k-element combinations from an iterable. This is a safe version that creates a new array for each combination.