permutations

Lazily computes all permutations of r using Heap's algorithm.

  1. Permutations!Range permutations(Range r)
    permutations
    (
    Range
    )
    (
    Range r
    )
    if (
    isRandomAccessRange!Range &&
    hasLength!Range
    )
  2. struct Permutations(Range)

Return Value

Type: Permutations!Range

A forward range the elements of which are an std.range.indexed view into r.

Examples

1 import std.algorithm.comparison : equal;
2 import std.range : iota;
3 assert(equal!equal(iota(3).permutations,
4     [[0, 1, 2],
5      [1, 0, 2],
6      [2, 0, 1],
7      [0, 2, 1],
8      [1, 2, 0],
9      [2, 1, 0]]));

See Also

Meta