The OpenD Programming Language

combinationsRepeat

Lazily computes all k-combinations of r with repetitions. A k-combination with repetitions, or k-multicombination, or multisubset of size k from a set S is given by a sequence of k not necessarily distinct elements of S, where order is not taken into account. Imagine this as the cartesianPower filtered for only ordered items.

While generating a new combination with repeats is in O(k), the number of combinations with repeats is binomial(n + k - 1, k).

  1. CombinationsRepeat!T combinationsRepeat(size_t n, size_t k)
  2. IndexedRoR!(CombinationsRepeat!T, Range) combinationsRepeat(Range r, size_t k)
    combinationsRepeat
    (
    T = uint
    Range
    )
    (
    Range r
    ,
    size_t k = 1
    )
    if (
    __traits(compiles, Range.init[size_t.init])
    )

Parameters

r Range

random access field. A field may not have iteration primitivies.

k size_t

number of combinations

Return Value

Type: IndexedRoR!(CombinationsRepeat!T, Range)

Forward range, which yields the k-multicombinations items

See Also

Meta