I’m in the process of writing a matrix transpose function in lisp. My approach can be seen from the following code:
(defun matrix-T (matrix)
(cond ((null matrix) matrix)
(t (list
(do ((i 0 (+ i 1)))
((> i (length matrix)))
(format t "(mapcar #'(lambda (x)(nth ~A x)) matrix) %" i))))))
As you can see, I’m trying to get the output from the do loop to pass as an
argument for the list function. However, I only get the do loop output returned from matrix-T. Is there anyway I can rectify this?
A dead-simple straight forward way to transpose a matrix: