The OpenD Programming Language

makeCombinationsRepeat

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).

makeCombinationsRepeat
(
T = uint
Allocator
)
(
auto ref Allocator alloc
,
size_t n
,
size_t repeat
)
if (
T.sizeof <= size_t.sizeof
)

Parameters

n size_t

number of elements (|r|)

alloc Allocator

custom Allocator

Return Value

Type: CombinationsRepeat!T

Forward range, which yields the k-multicombinations items

See Also

Meta