Personally I prefer to use a non-iterator style, so I combine (my own) zip with pair from List::Pairwise.
The main reason I like pair over natatime is that it's easy to combine with any expression/subroutine that requires the whole list and in particular sort (but also map and grep). For instance:for (pair(zip($array1, $array2))) { my ($x, $y) = @$_; # It's often descriptive to name the values. ... }
The reason I don't use zip from List::MoreUtils is that it's prototyped with (\@\@;\@...) which I find counter-intuitive, as I imagine you do too as you passed in $array1 instead of @$array1. It's also more in the way than it's helping, as I frequently end up with wanting to zip the result of an expression instead of an array or having a list or an array holding array references.for ( sort { $a->[0] <=> $b->[0] or $a->[1] cmp $b->[1] } pair zip($array1, $array2) ) { my ($number, $char) = @$_; ... }
lodin
In reply to Re^2: parallel procesing (List::Pairwise)
by lodin
in thread parallel procesing
by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |