Thread overview | |||||
---|---|---|---|---|---|
|
July 20, 2011 skip(N) range | ||||
---|---|---|---|---|
| ||||
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 Re: skip(N) range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam Wey | 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 Re: skip(N) range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam Wey | 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 |
Copyright © 1999-2021 by the D Language Foundation