std.range.chunk without length

Stephan Schiffels stephan_schiffels at mac.com
Tue Oct 29 17:20:06 PDT 2013


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]);
   }
}

Thanks,
Stephan


More information about the Digitalmars-d-learn mailing list