19/03/10 17:47:53.28 lsf+n+kn.net
>>544 Perl5
@a = ([1, 2, 3,],
[4, 5, 6]);
use List::Util sum;
push @$_, sum(@$_) for @a;
for $i (0..$#{$a[0]}) {
push @b, sum(map{$a[$_][$i]} 0..$#a)
}
print "@$_\n" for @a;
print "@b\n";
実行結果
~ $ perl 13_544.pl
1 2 3 6
4 5 6 15
5 7 9 21