It would be nice if `chunks` would accept only an InputRange too. Let me show you a common pattern that I often use: // iterate over two lines in a pair and compute the difference between them // 1 2 // 2 3 // => 2 stdin.byLineCopy.map!(x => x.splitter(' ').map!(to!int)).chunks(2)).map(x => abs(x.frontPop - x.front); ); This currently doesn't compile, because `chunks` doesn't buffer, it saves the state of the forward range. However adding support for normal Input Ranges shouldn't can easily done using a local buffer - I already wrote the code at some point: https://github.com/greenify/d-itertools/blob/4afbc804e8b50c797fa206969dc3b4934911a0b9/source/splitwise.d I would be happy to wrap this up nicely and bring it into a phobos shape - any thoughts/concerns?
https://github.com/dlang/phobos/pull/5624
Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6826427ba55b9ae9a0f64f4489c359a851e08087 Fix issue 15759: Extend std.range.chunks to work with non-forward input ranges. Add input range example.
Commit pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6826427ba55b9ae9a0f64f4489c359a851e08087 Fix issue 15759: Extend std.range.chunks to work with non-forward input ranges.
Commit pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6826427ba55b9ae9a0f64f4489c359a851e08087 Fix issue 15759: Extend std.range.chunks to work with non-forward input ranges.