Thread overview
skip(N) range
Jul 20, 2011
Adam Wey
Jul 20, 2011
Jonathan M Davis
Jul 20, 2011
Jesse Phillips
July 20, 2011
Is there a skip() function for ranges? I need to skip N elements of a range and then take M elements. Something like

writeln(take(range, 10), ": ", take(skip(range, 10), 10));

Thanks
July 20, 2011
On 2011-07-19 17:29, Adam Wey wrote:
> Is there a skip() function for ranges? I need to skip N elements of a range and then take M elements. Something like
> 
> writeln(take(range, 10), ": ", take(skip(range, 10), 10));

No, but this pull request

https://github.com/D-Programming-Language/phobos/pull/147

will introduce the drop function which does that. It hasn't been merged in yet though. The closest that there is right now is to call popFrontN, but you can't do that in the middle of an expression like that.

- Jonathan M Davis
July 20, 2011
Adam Wey Wrote:

> Is there a skip() function for ranges? I need to skip N elements of a range and then take M elements. Something like
> 
> writeln(take(range, 10), ": ", take(skip(range, 10), 10));
> 
> Thanks

There is popFrontN

http://d-programming-language.org/phobos/std_range.html#popFrontN