It has just occurred to me that the digit check might only be there because you were using a buggy for loop. If so, the solutions are much simpler.
for:
my @fulls; for my $area (@areas) { for my $short (@shorts) { push @fulls, "$short.area$area"; } }
map:
my @fulls = map { my $area = $_; map "$_.area$area", @shorts } @areas;
More intuitive map, but different order produced:
my @fulls = map { my $short = $_; map "$short.area$_", @areas } @shorts;
NestedLoops:
use Algorithm::Loops qw( NestedLoops ); my @fulls = NestedLoops( [ \@areas, \@shorts ], sub { "$_[1].area$_[0]" }, );
In reply to Re: Can map or splice replace my use of for loop + push + grep for my array transmogrification?
by ikegami
in thread Can map or splice replace my use of for loop + push + grep for my array transmogrification?
by jffry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |