Define a recursive Scheme function sumdiag that computes the sum of the elements on the secondary diagonal of a matrix.

Programming Languages

solve step by step

Define a recursive Scheme function sumdiag that computes the sum of the elements on the secondary diagonal of a matrix.The matrix is given as a list of lists, where each row is represented as a sublist.

Example: evaluates to 15 (3+5+7).

The recursive call in the definition of sumdiag should be made on a submatrix of the original obtained by removing the first row and the last column. That can be achieved by using map as follows: , where the function remove last acts on a list and removes the last element of the list.

 

© 2020 EssayQuoll.com. All Rights Reserved. | Disclaimer: For assistance purposes only. These custom papers should be used with proper reference.