The OpenD Programming Language

retro

Iterates a bidirectional range backwards. The original range can be accessed by using the source property. Applying retro twice to the same range yields the original range.

retro
(
Range
)
(
Range r
)
if (
isBidirectionalRange!(Unqual!Range)
)

Parameters

r Range

the bidirectional range to iterate backwards

Return Value

Type: auto

A bidirectional range with length if r also provides a length. Or, if r is a random access range, then the return value will be random access as well.

Examples

import std.algorithm.comparison : equal;
int[5] a = [ 1, 2, 3, 4, 5 ];
int[5] b = [ 5, 4, 3, 2, 1 ];
assert(equal(retro(a[]), b[]));
assert(retro(a[]).source is a[]);
assert(retro(retro(a[])) is a[]);

See Also

std.algorithm.mutation.reverse for mutating the source range directly.

Meta