is std.algorithm.joiner lazy?

Puming via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 7 01:17:38 PDT 2016


On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen 
wrote:
> On Thursday, 7 April 2016 at 07:07:40 UTC, Puming wrote:
>> [...]
>
> Apparently it works processing the first two elements at 
> creation. All the other elements will be processed lazily.
>
> Even when a range is lazy the algorithm still often has to 
> "consume" one or two starting elements, just to set initial 
> conditions. It does surprise me that joiner needs to process 
> the first two, would have to look at the implementation why.

OK. Even if it consumes the first two elements, then why does it 
have to consume them AGAIN when actually used? If the function 
mkarray has side effects, it could lead to problems.


More information about the Digitalmars-d-learn mailing list