[Openmcl-devel] Building tables with format
hamlink at comcast.net
Tue Aug 17 23:56:04 EDT 2004
Wow, good question! I love format. Mind you I never write a format
control string without CLTL2 handy...
After much searching, and deciding there was no straightforward way of
doing as you yourself discovered, I revisited the pretty printing
chapter of CLTL2. I think ~/.../ may do what you need. Look in section
27.4 of CLTL2, and check this out:
? (defun chop (s arg &optional colonp atsignp &rest parameters)
(let ((full-result (format nil "~a" arg)))
(format s "~a" (subseq full-result 0 (min 10 (length
? (format nil "~1,2,3:@/CHOP/" "This string is far, far too long!")
;; this was all my debugging output
"This string is far, far too long!"
(1 2 3)
;; this was what was printed by the format command, using CHOP
And of course you could make chop take minlength, maxlength, and
padchar as parameters and DWYM.
On Aug 17, 2004, at 10:06 AM, Camille Troillard wrote:
> I fear my question is a little bit off topic.
> I would like to output a table with fixed-width cells. This means I
> need to truncate string arguments in order to keep the cell width
> constant. FORMAT offers a way to add a padding, but there is not way
> to truncate a string argument (I would have used an option to the ~A
> or ~S directives).
> Is there any way to extend OpenMCL's FORMAT mechanism in order to do
> just that?
> Thanks for your help,
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel