[Openmcl-devel] Building tables with format
tuscland at mac.com
Wed Aug 18 09:22:03 UTC 2004
Wow, impressive, this is exactly what I searched for.
Thank you very much!!!
On 18 août 04, at 05:56, Hamilton Link wrote:
> 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)
> (print s)
> (print arg)
> (print colonp)
> (print atsignp)
> (print 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
> #<STRING-OUTPUT-STREAM #x8155244E>
> "This string is far, far too long!"
> (1 2 3)
> ;; this was what was printed by the format command, using CHOP
> "This strin"
> 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