StoppingPolicy.longest never stop?

tsukikage tsukikage at dmail.com
Sat Jan 29 22:31:28 PST 2011


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_


More information about the Digitalmars-d-learn mailing list