Transposing lists in Common Lisp
问题 I am trying to transpose a list of lists; my comments indicate the thought process. (setq thingie '((1 2 3) (4 5 6) (7 8 9))) ;;test case (defun trans (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 (trans bottom)))) ;;cons the first-row-list with the next-row-list mat) (trans 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