http://qs1969.pair.com?node_id=1211523


in reply to perl6 matrix arrayof arrays

cannot use @arr[0].elems : gives an error

Like @arr vs $#arr in Perl, I'm guessing @arr[0].elems was causing warnings for accessing the element just after the end of an array.

A possible alternative coding:

use v6; my @arr = [ [ 1.1,2.2,3.3,4.4,5.5 ], [ 10,20,30,40,50 ], [ 100,200,300,400,500 ], [ 1000,2000,3000,4000,5000 ], ]; dd @arr; # dump the matrix for @arr { say ( .map: {.fmt: "%7.1f\t"} ).join } say "=======\t" x @arr[0].elems; say ( (0..@arr[0].end).map: {@arr[*; $_].sum.fmt("%7.1f\t")} ).join; #say ( ([Z] @arr).map: { .sum.fmt("%7.1f\t") } ).join;
Ron