Combining "chunkBy" and "until" algorithms

Edwin van Leeuwen via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 4 08:23:51 PDT 2016


On Friday, 4 November 2016 at 08:04:12 UTC, Jacob Carlborg wrote:
> Currently I'm using a standard for loop iterating over the 
> lines. I'm always looking at the current line and the next 
> line. When the current line is the standard pattern and the 
> next line is is not, I do a separate loop until I see a 
> standard pattern again, collecting the lines with the 
> non-standard pattern in an array.

Could you filter [1] for the non standard pattern? Filter is 
lazy, so will only start looking for the next when the current 
one has been "handled".

[1] https://dlang.org/phobos/std_algorithm_iteration.html#.filter



More information about the Digitalmars-d-learn mailing list