This seems to work as well:
use Modern::Perl; my @array = ( [ qw/ 1 1 1 1 1 / ], [ qw/ 0 1 1 0 0 / ], [ qw/ 0 0 0 0 1 / ], [ qw/ 0 0 0 0 0 / ], [ qw/ 0 1 0 1 0 / ], ); my $rownumber = 0; for my $row (@array) { do {say "row $rownumber has all zeroes"; last} unless (join '', @$ +row)+0; $rownumber++ }
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: An exploration of higher-level-language approaches to the "First all-zero row in an NxN matrix" problem (goto Considered Harmful)
by davido (Cardinal) on Sep 24, 2011 at 20:18 UTC | |
Re^2: An exploration of higher-level-language approaches to the "First all-zero row in an NxN matrix" problem (goto Considered Harmful)
by moritz (Cardinal) on Sep 24, 2011 at 20:24 UTC |
In Section
Meditations