Programming-Idioms

History of Idiom 43 > diff from v6 to v7

Edit summary for version 7 :

Version 6

2015-08-01, 17:37:04

Version 7

2015-08-01, 17:37:45

Idiom #43 Break outer loop

Look for a negative value v in 2D integer matrix m. Print it and stop searching.

Idiom #43 Break outer loop

Look for a negative value v in 2D integer matrix m. Print it and stop searching.

Code
OUTER:
for my $i (0 .. $#m) {
   for $j (0 .. $#{$m[$i]}) {
      if ($m[$i][$j] == $v) {
         print "$v\n";
         last OUTER;
      }
   }
}
Code
OUTER:
for my $i (0 .. $#m) {
   for $j (0 .. $#{$m[$i]}) {
      if ($m[$i][$j] < 0) {
         print "Negative value found: $v\n";
         last OUTER;
      }
   }
}