Replacement for Zip/Lockstep

jerro jkrempus at gmail.com
Sun Mar 16 18:11:31 PDT 2014


> I prefer the "shortest", because it's used in various 
> languages, and it works well when one given range is finite and 
> the other is infinite:
>
> zip([10, 20, 7, 3), [1, -1].cycle)

The policy requireSameLenght could be changed so that it would
ignore the empty property of infinite ranges. Then your example
would still work with it. Or, alternatively,
requireSameLengthOrInfinite could be added.

I don't think that allowing multiple finite ranges with different
numbers of elements is a very good default. Code that 
intentionally
passes finite ranges with different lengths to zip() is probably
pretty rare (code that does it unintentionally may be more 
common).
And even when such code is correct, being explicit about it would
make it clearer.


More information about the Digitalmars-d mailing list