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 >                frobnic

Re: flow control and nested loops

2009-09-26 Thread Raymond Hettinger
On Sep 25, 12:01 pm, 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(

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); } What's

Re: flow control and nested loops

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 3:01 PM, 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); >    } >