tsukikage wrote:
Why this zip not stop after iterated through the longest range? thanks!

import std.stdio, std.range ;
void main() {
    auto a = [1,2,3,4] ;
    auto b = [6,7,8,9] ;
    auto c = "ABCDE" ;   // <= longest range here
    auto d = "ZYXW" ;
    auto CNT = 0 ;
    foreach(p; zip(StoppingPolicy.longest, a,b,c, d))
        if(CNT++ < 30)
            writefln("%s %s %s %s", p[0],p[1],p[2], p[3]) ;
        else
            break ;
}

output:
1 6 A Z
2 7 B Y
3 8 C X
4 9 D W
0 0 E ￿
0 0 ￿ ￿
0 0 ￿ ￿ <= this continue infinitely if not supply a stopping _CNT_

note: ￿ is 0xffff (wchar init?) print as "%s"

Reply via email to