Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 30, 2011 StoppingPolicy.longest never stop? | ||||
---|---|---|---|---|
| ||||
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_ |
January 30, 2011 Re: StoppingPolicy.longest never stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to tsukikage | 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"
|
January 30, 2011 Re: StoppingPolicy.longest never stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to tsukikage | tsukikage: > Why this zip not stop after iterated through the longest range? thanks! http://d.puremagic.com/issues/show_bug.cgi?id=5506 Bye, bearophile |
January 31, 2011 Re: StoppingPolicy.longest never stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile wrote:
> tsukikage:
>
>> Why this zip not stop after iterated through the longest range? thanks!
>
> http://d.puremagic.com/issues/show_bug.cgi?id=5506
>
> Bye,
> bearophile
Thank you!
|
Copyright © 1999-2021 by the D Language Foundation