in reply to perl6 matrix arrayof arrays
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl6 matrix arrayof arrays
by Anonymous Monk on Mar 22, 2018 at 14:31 UTC | |
by mr_ron (Deacon) on Mar 22, 2018 at 19:13 UTC |