Range with lookaround

Dukc via Digitalmars-d digitalmars-d at puremagic.com
Fri Mar 3 03:22:37 PST 2017


On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu 
wrote:
> May be worth discussing in here: 
> https://issues.dlang.org/show_bug.cgi?id=17238 -- Andrei

//My understanding of the concept, is this correct?
assert(iota(5).lookAhead(1, 2).array ==
[   [0, 1],
     [0, 1, 2],
     [0, 1, 2, 3],
     [1, 2, 3, 4],
     [2, 3, 4],
     [3, 4],
     [4]
]);

I would prefer if the second argument meant length, not distance 
to look back. So the call equivalent to the one above would be 
lookAhead(-2, 4).


More information about the Digitalmars-d mailing list