Skip to content

2013-5: Identity Crisis

An identity matrix is a square matrix (table) of 0 with 1's in the main diagonal.

Write an APL dfn which produces an n×n identity matrix.

Examples:

      (your_function) 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
      (your_function) 1 ⍝ should return a 1×1 matrix
1
      (your_function) 0 ⍝ should return a 0×0 matrix
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub