This module contains various combinatorics algorithms.

Authors

Sebastian Wilzbach, Ilya Yaroshenko

Example

import mir.ndslice.fuse;

assert(['a', 'b'].permutations.fuse == [['a', 'b'], ['b', 'a']]);
assert(['a', 'b'].cartesianPower(2).fuse == [['a', 'a'], ['a', 'b'], ['b', 'a'], ['b', 'b']]);
assert(['a', 'b'].combinations(2).fuse == [['a', 'b']]);
assert(['a', 'b'].combinationsRepeat(2).fuse == [['a', 'a'], ['a', 'b'], ['b', 'b']]);

assert(permutations!ushort(2).fuse == [[0, 1], [1, 0]]);
assert(cartesianPower!ushort(2, 2).fuse == [[0, 0], [0, 1], [1, 0], [1, 1]]);
assert(combinations!ushort(2, 2).fuse == [[0, 1]]);
assert(combinationsRepeat!ushort(2, 2).fuse == [[0, 0], [0, 1], [1, 1]]);

assert([3, 1].permutations!ubyte.fuse == [[3, 1], [1, 3]]);
assert([3, 1].cartesianPower!ubyte(2).fuse == [[3, 3], [3, 1], [1, 3], [1, 1]]);
assert([3, 1].combinations!ubyte(2).fuse == [[3, 1]]);
assert([3, 1].combinationsRepeat!ubyte(2).fuse == [[3, 3], [3, 1], [1, 1]]);

Functions

binomialReturns:

Binomial coefficient

indexedRoRReturns:

, , ,

permutations@safe, pure, nothrowReturns:
permutations@safe, pure, nothrowReturns:
makePermutationsReturns:
dispose
cartesianPower@safe, pure, nothrowReturns:
cartesianPowerReturns:
makeCartesianPowerReturns:
dispose
combinations@safe, pure, nothrowReturns:
combinationsReturns:
makeCombinationsReturns:
dispose
combinationsRepeat@safe, pure, nothrowReturns:
combinationsRepeatReturns:
makeCombinationsRepeatReturns:
dispose

Structs

IndexedRoRReturns:

, , ,

Permutations
CartesianPower
Combinations
CombinationsRepeat

Templates

isArithmetic
isArithmetic