Re: flow control and nested loops

2009-09-26 Thread Raymond Hettinger
On Sep 25, 12:01 pm, kj no.em...@please.post wrote: In Perl, one can label loops for finer flow control.  For example: X: for my $x (@X) {   Y: for my $y (@Y) {     for my $z (@Z) {       next X if test1($x, $y, $z);       next Y if test2($x, $y, $z);       frobnicate($x, $y, $z);     }  

Re: flow control and nested loops

2009-09-26 Thread Bearophile
Raymond Hettinger: Another approach for exiting multiple levels of loops is wrap the inner calls in a function and return from them when needed:    def f(x):        for y in y:            for z in Z:                if test1(x,y,z):                    return                

flow control and nested loops

2009-09-25 Thread kj
In Perl, one can label loops for finer flow control. For example: X: for my $x (@X) { Y: for my $y (@Y) { for my $z (@Z) { next X if test1($x, $y, $z); next Y if test2($x, $y, $z); frobnicate($x, $y, $z); } glortz($x, $y); } splat($x); } What's considered

Re: flow control and nested loops

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 3:01 PM, kj no.em...@please.post wrote: In Perl, one can label loops for finer flow control.  For example: X: for my $x (@X) {  Y: for my $y (@Y) {    for my $z (@Z) {      next X if test1($x, $y, $z);      next Y if test2($x, $y, $z);      frobnicate($x, $y, $z);

Re: flow control and nested loops

2009-09-25 Thread Terry Reedy
kj wrote: In Perl, one can label loops for finer flow control. For example: X: for my $x (@X) { Y: for my $y (@Y) { for my $z (@Z) { next X if test1($x, $y, $z); next Y if test2($x, $y, $z); frobnicate($x, $y, $z); } glortz($x, $y); } splat($x); }