View source code
Display the source code in std/range.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.range.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.
Prototype
auto retro(Range)( Range r ) if (isBidirectionalRange!(Unqual!Range));
Example
import std.algorithm : equal; int[] a = [ 1, 2, 3, 4, 5 ]; assert(equal(retro(a), [ 5, 4, 3, 2, 1 ][])); assert(retro(a).source is a); assert(retro(retro(a)) is a);
Authors
Andrei Alexandrescu, David Simcha, and Jonathan M Davis. Credit for some of the ideas in building this module goes to Leonardo Maffi.