in reply to Re: iterating 2 arrays in parallel
in thread iterating 2 arrays in parallel
pairwise from List::MoreUtils requires that both arrays have the same length, you can get the same behaviour easily without using any extra module at all:
my @combined = map {"$a1[$_]:$a2[$_]"} ($#a1 < $#a2 ? (0..$#a2) : (0.. +$#a1));
This version can be easily fixed to treat arrays of different length:
my @combined = map {($a1[$_]//"").":".($a2[$_]//"")} ($#a1 < $#a2 ? (0 +..$#a2) : (0..$#a1));
citromatik
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: iterating 2 arrays in parallel
by linuxer (Curate) on Apr 15, 2009 at 10:37 UTC | |
by JavaFan (Canon) on Apr 15, 2009 at 10:55 UTC | |
by linuxer (Curate) on Apr 15, 2009 at 11:03 UTC |