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)
    @safe pure nothrow
    combinations
    (
    T = uint
    )
    (
    size_t n
    ,
    size_t k = 1
    )
    if (
    T.sizeof <= size_t.sizeof
    )
  2. IndexedRoR!(Combinations!T, Range) combinations(Range r, size_t k)

Parameters

n size_t

number of elements (|r|)

k size_t

number of combinations

Return Value

Type: Combinations!T

Forward range, which yields the k-combinations items

See Also

Meta