format - Help with printing a table

Posted by Michael Kohl on Stack Overflow See other posts from Stack Overflow or by Michael Kohl
Published on 2011-01-06T18:42:53Z Indexed on 2011/01/06 21:53 UTC
Read the original article Hit count: 202

Filed under:
|
|

This question will probably end in a facepalm, but I've tried for a while and am still stuck despite reading through the hyperspec.

Basically what I want to do is something like

(format t "~{|~{ ~5d~}|~%~}" '((1 23 2 312) (23 456 1 7890)))

but instead of hard-coding the 5 it should be calculated from the list (length of longest element from any nested list + 1) to give something like

|    1    23     2   312|
|   23   456     1  7890|      

Maybe I'm thinking way too complicated here and there is an easier way to do what I want, but I think I ran myself into a mental corner that I can't get out of.

© Stack Overflow or respective owner

Related posts about lisp

Related posts about output