The OpenD Programming Language

combinations

Lazily computes all k-combinations of r. Imagine this as the cartesianPower filtered for only strictly ordered items.

While generating a new combination is in O(k), the number of combinations is binomial(n, k).

  1. Combinations!T combinations(size_t n, size_t k)
  2. IndexedRoR!(Combinations!T, Range) combinations(Range r, size_t k)
    combinations
    (
    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!(Combinations!T, Range)

Forward range, which yields the k-combinations items

See Also

Meta