std.range.chunk without length

Stephan Schiffels stephan_schiffels at mac.com
Thu Oct 31 03:35:53 PDT 2013


On Wednesday, 30 October 2013 at 20:43:54 UTC, qznc wrote:
> On Wednesday, 30 October 2013 at 00:20:12 UTC, Stephan 
> Schiffels wrote:
>> Hi,
>>
>> I'd like a version of std.range.chunk that does not require 
>> the range to have the "length" property.
>>
>> As an example, consider a file that you would like parse by 
>> lines and always lump together four lines, i.e.
>>
>> import std.stdio;
>> void main() {
>>  auto range = File("test.txt", "r").byLine();
>>  foreach(c; range.chunks(4)) { //doesn't compile
>>    writefln("%s %s", c[0], c[1]);
>>  }
>> }
>
> Your wish was granted. Monarchdodra was sent back in time [0], 
> so it is already fixed in HEAD. You could try the dmd beta [1].
>
>
> [0] https://github.com/D-Programming-Language/phobos/pull/992
> [1] 
> http://forum.dlang.org/thread/526DD8C5.2040402@digitalmars.com

Ah, awesome! Should have updated my github clone then.
Thanks,
Stephan



More information about the Digitalmars-d-learn mailing list