in reply to performing a function on corresonding array elements

Algorithm::Loops also handles parallel looping wonderfully:

use Algorithm::Loops qw( MapCarU ); use List::Util qw( sum ); my @items = map { $_->{items} } @sets; my @totals = MapCarU { sum( @_ ) } @items;

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^2: performing a function on corresonding array elements (w/o temp)
by tye (Sage) on Apr 03, 2006 at 18:23 UTC

    And, of course, it also works without the temporary array variable:

    ... my @totals= MapCarU { sum( @_ ) } map $_->{items}, @sets;

    - tye        

      Which is exactly how I'd write it for myself. I thought I'd opt to be clearer.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊