in reply to perl6 matrix arrayof arrays

When you get used to the way functions work with lists, you might start writing it more like the following.
(Then again maybe not; it could be that I'm just really used to doing code golfs.)

# calls .fmt on each array which then calls .fmt on the elements # the results of which are implicitly joined with a space # print the result with trailing newline .fmt("%7.1f").put for @arr; # if it must be tab separated # $_».fmt("%7.1f").join("\t").put for @arr; # repeat '=' as a string 7 times, and list repeat that # coerce to Str (space separated) and print with newline put '=' x 7 xx @arr[0]; # if it must be tab separated # put ('=' x 7 xx @arr[0]).join("\t"); # add the values in the columns up and format them put [Z+](@arr).fmt("%7.1f"); # if it must be tab separated # put [Z+](@arr)».fmt("%7.1f").join("\t");

At the very least I wouldn't use loop for most purposes, as it's easy to get off-by-one errors and to accidently mutate the iterator variable in the block. Also the iterator variable in a loop construct is scoped to the outer block, not the loop block.

for @arr -> @inner { for @inner -> $_ { print .fmt("%7.1f\t"); } put(); # use the value of $*OUT.nl-out } ... for [Z+] @arr { print .fmt("%7.1f\t"); LAST put(); } }