From 25286e22f95803373bc26850f43cc0284b73ff0c Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Mon, 12 Jan 2009 08:21:14 +0100 Subject: [PATCH] added transpose-listoflists. What a trivial function (in the sense that it is trivial when you understand CL) --- TODO.lisp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TODO.lisp b/TODO.lisp index f5ef222..3459206 100644 --- a/TODO.lisp +++ b/TODO.lisp @@ -181,7 +181,17 @@ further processing and initial conditions." aluminum iron)) - + (defun transpose-listoflists (listoflists) + "This function does the moral-equivalent of a matrix transpose on + a list-of-lists data structure" + (apply #'mapcar #'list listoflists)) + + ;; (defparameter LOL-2by3 (list (list 1 2) (list 3 4) (list 5 6))) + ;; (values-list LOL-2by3) + ;; (apply #'mapcar #'list LOL-2by3) + ;; (transpose-listoflists (transpose-listoflists LOL-2by3)) + ;; => (list (list 1 3 5) (list 2 4 6)) + ;; (mapcar #'list LOL-2by3) ;; The below FAILS due to coercion issues; it just isn't lispy, it's R'y. #| -- 2.11.4.GIT