Find main diagonal in matrix - Scheme
I need to extract the main diagonal from a square matrix (1 2 3) (4 5 6) -> (1 5 9) (7 8 9) I have the following code and I need to replace the ... with the appropriate functions. (define (diag m) (if (null? m) '() (cons (... m) (diag (map ... (... m)))))) Input: (diag '((1 2 3) (4 5 6) (7 8 9))) Output: (1 5 9) Any ideas? Thank you! So you are asking, given you have the list '((1 2 3) (4 5 6) (7 8 9)) how do I get the value 1 from it? Then you are asking given the same list, how do I get ((4 5 6) (7 8 9)) from it. Then given that result how do I make a new list using map that only takes the