digitalmars.D.learn - skip(N) range
- Adam Wey (4/4) Jul 19 2011 Is there a skip() function for ranges? I need to skip N elements of a ra...
- Jonathan M Davis (7/11) Jul 19 2011 No, but this pull request
- Jesse Phillips (3/9) Jul 19 2011 There is popFrontN
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
Jul 19 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
Jul 19 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)); ThanksThere is popFrontN http://d-programming-language.org/phobos/std_range.html#popFrontN
Jul 19 2011