Function retro

Iterates a bidirectional range backwards.

auto retro(Range) (
  Range range
)
if (isBidirectionalRange!Range);

If Range is a random-access range as well, the resulting range is a random-access range too.

Parameters

NameDescription
Range Bidirectional range type.
range Bidirectional range.

Returns

Bidirectional range with the elements order reversed.

Example

import tanya.algorithm.comparison : equal;

const int[3] given = [1, 2, 3];
const int[3] expected = [3, 2, 1];

auto actual = retro(given[]);

assert(actual.length == expected.length);
assert(!actual.empty);
assert(equal(actual, expected[]));