in reply to Re^2: Parallel processing two arrays with different numbers of elements
in thread Parallel processing two arrays with different numbers of elements

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.)

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^4: Parallel processing two arrays with different numbers of elements
by ww (Archbishop) on Sep 15, 2013 at 12:21 UTC

    Nice, but...

    return if $i > $#arr || $i > $#bar;

    ...doesn't report "different numbers of elements."

    If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.