Estoy tratando de transponer una lista de listas; mis comentarios indican el proceso de pensamiento.Transposición de listas en Common Lisp
(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?
Pero, realmente quieren que sea
((1 4 7) (2 5 8) (3 6 9))
¿Qué estoy haciendo mal?
Esto se llama [matriz transpuesta] (http://en.wikipedia.org/wiki/Transpose). – sds
@sds: ... yuuup. Por qué no lo vi hace 3 años me supera. Dame unos minutos y arreglaré esto. –