For literal lists, I'd probably bypass the prototype:
&pairwise( sub { $a => $b }, \@a, ['a'..'d'], );
Or if you need to do it a lot, maybe wrap it with a different prototype:
sub ref_pairwise (&;@) { goto \&List::Util::pairwise } ref_pairwise { $a + $b } \@a, ['a'..'d'];
Limiting to the size of the arrays needs to be added explicitly to the block, but isn't especially challenging:
use v5.12; use List::MoreUtils; my @arr = qw/a b c d e/; my @bar = qw/12 34 56/; my $i = 0; List::MoreUtils::pairwise { return if $i > $#arr || $i > $#bar; say "\t$i"; say "\t\t$a, $b"; $i++; } @arr, @bar;
(It would be more sugary if that return could be a last, but ho hum.)
In reply to Re^3: Parallel processing two arrays with different numbers of elements
by tobyink
in thread Parallel processing two arrays with different numbers of elements
by ww
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |