lookahead on ranges
Sebastian Graf
SebastianGraf at t-online.de
Mon Apr 29 09:23:08 PDT 2013
Hi,
is there any way to to something like
auto arr = [1,2,3,4,5];
auto delta = arr.lookahead!"b-a"(1); // or probably pass 1 as
template arg
assert(equal(delta[], [1,1,1,1][]);
or like
// lookahead returns range of tuples (template arg) or arrays
(runtime arg)
foreach (a, b; arr.lookahead!1)
writeln(b-a);
on a range? I think I could possibly do this with zip, but I am
curious if there is something more to the point to do it in
phobos. In particular something that just buffers n eles and does
not copy the input range to popFront() all of them.
More information about the Digitalmars-d-learn
mailing list