I have a list of lists [(1 2 3) (4 5 6) (7 8 9)] which is for a matrix. I am looking for how to get the diagonal( which should be (1 5 9). My code provides me with an error "OPERATOR IS NOT A PROCEDURE". i dont know exactly what i did wrong in this. Help would be appreciated.THE CODE IS BELOW.
(define (diagonal lst)
(if(null? lst)
(0)
((cons (list-ref (reverse (car lst)) (- (length lst) 1)) (diagonal (cdr lst))))))