I am trying to swap 'rows' and 'columns' in common lisp. Comments delineate my logic.
(setq thingie '((1 2 3) (4 5 6) (7 8 9))) ;;test case
(defun rotate (mat)
(if (car mat)
(let ((top (mapcar 'car mat)) ;;slice the first row off as a list
(bottom (mapcar 'cdr mat))) ;;take the rest of the rows
(cons top (rotate bottom)))) ;;cons the first-row-list with the next-row-list
mat) ;;nil case, okay to cons in...
(rotate thingie)
=> ((1 2 3) (4 5 6) (7 8 9)) ;;wait what?
But, I really want it to be
((1 4 7) (2 5 8) (3 6 9))
What am I doing wrong?