The OpenD Programming Language

cartesianPower

Lazily computes the Cartesian power of r with itself for a number of repetitions D repeat. If the input is sorted, the product is in lexicographic order.

While generating a new item is in O(k) (amortized O(1)), the total number of elements is n^k.

  1. CartesianPower!T cartesianPower(size_t n, size_t repeat)
  2. IndexedRoR!(CartesianPower!T, Range) cartesianPower(Range r, size_t repeat)
    cartesianPower
    (
    T = uint
    Range
    )
    (
    Range r
    ,
    size_t repeat = 1
    )
    if (
    __traits(compiles, Range.init[size_t.init])
    )

Parameters

r Range

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

repeat size_t

number of repetitions

Return Value

Type: IndexedRoR!(CartesianPower!T, Range)

Forward range, which yields the product items

See Also

Meta