aboutsummaryrefslogtreecommitdiff
path: root/challenge-011/ozzy/perl6/ch-2.p6
blob: 346fc299d27582c5caed60c378be05705ba1217b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl6
#
# Compose and print identity matrix
#
# Notes:
# - "is default" trait not implemented for shaped arrays
# - Partially dimensioned views of shaped arrays not yet implemented
# - Could use Math::Matrix

sub MAIN (Int $dim)
{
    my @md[$dim;$dim];

    for 0..$dim-1 -> $i {
        for 0..$dim-1 -> $j {
            @md[$i;$j]= $i==$j ?? 1 !! 0;
            printf "%3i", @md[$i;$j];
        }
    printf "\n";
    }
}