Another example: using a beautiful printer for fun:
(defun print-list-as-matrix (list elements-per-row &optional (cell-width (1+ (truncate (log (apply
It works as follows:
CL-USER> (print-list-as-matrix (loop for i from 1 to 9 collect i) 3) 1 2 3 4 5 6 7 8 9 NIL CL-USER> (print-list-as-matrix (loop for i from 1 to 25 collect i) 5) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 NIL CL-USER> (print-list-as-matrix (loop for i from 1 to 16 collect i) 2) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
source share