Circular Buffer
Gary Willoughby
dev at nomad.so
Mon Feb 10 01:16:30 PST 2014
On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap
wrote:
> (disclaimer: I'm new around here)
> Is it possible to cycle backwards? If not, what's the best
> approach?
import std.algorithm;
import std.array;
import std.range;
import std.stdio;
void main(string[] args)
{
auto data = [1,2,3];
assert(data.cycle.take(5).array == [1,2,3,1,2]);
assert(data.retro.cycle.take(5).array == [3,2,1,3,2]);
}
More information about the Digitalmars-d-learn
mailing list