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);
}
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
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
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);
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);
}