7. More Identity Matrices
Note: In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your function will be checked by the APL Challenge system using several tests to see whether it is correct.
You can create your own function by putting an expression (for example, ⍳10) in curly brackets (for example, {⍳10}). Within this expression (in our example, ⍳10), any ⍵ (omega, the right-most letter of the Greek alphabet) is replaced by the argument to the right of the closing curly bracket ( } ).
For example, a function that multiplies its argument by two could be written {2×⍵}, so {2×⍵} 5 gives 10.
Using what you learnt in problem 6, write a function that gives an identity matrix of the given size. For example:
{answer} 5
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
{answer} 2
1 0
0 1
{answer} 6
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1