Another cool mini-project: advance a range within n steps from its end

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 4 12:01:10 PST 2015


On 2015-12-04 17:37, Andrei Alexandrescu wrote:
> Like "tail" in Unix. Given a range R r and a number size_t n, return a
> TakeExactly!R that's r at no more than n steps from its end:
>
> TakeExactly!R advanceWithin(R)(R r, size_t n)
> if (isForwardRange!R);
>
> Invariant:
>
> assert(r.advanceWithin(n).length <= n);
>
> Implementation would send a scout range ahead, etc.
>
> I didn't file an issue for it, but it's a great function to have.

retro + take?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list