Given positive ints r and c indicating number of rows and columns, create a 2D list that represents the "augmented identity matrix" with that dimension: It's the r x c matrix of all zeroes, except the main diagonal is all ones.
NOTE: I am not allowed to use global variables.
Function format:
(defun augdentity (r c) … )
Sample runs:
* (augdentity 3 3)
((1 0 0) (0 1 0) (0 0 1))
* (augdentity 3 5)
((1 0 0 0 0) (0 1 0 0 0) (0 0 1 0 0))
* (augdentity 5 3)
((1 0 0) (0 1 0) (0 0 1) (0 0 0) (0 0 0))
* (augdentity 2 2)
((1 0) (0 1))
This is the Haskell version of the function but I couldn't figure out how to do it in Lisp
augdentity :: Int -> Int -> [[Int]]
augdentity r c = [[if row == col then 1 else 0 | col <- [1 .. c]] | row <- [1 .. r]]
Well, you can translate that pretty directly using
loop: