[racket] Output Different Column Widths in a Table

From: Laurent (laurent.orseau at gmail.com)
Date: Wed Nov 27 09:58:21 EST 2013

`pretty-print' is not really meant to print tables. You probably want to
use `~a' instead, which has various arguments related to width:
http://docs.racket-lang.org/reference/strings.html?q=~a#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ea%29%29

For example:
(for ([s '("auie" "bépoauie" 5 10)]
      [w '(10 4 8 2)])
  (display (~a s #:width w)))

Laurent


On Mon, Nov 25, 2013 at 5:39 PM, Eli Nistal <emnistal at gmail.com> wrote:

> Hello,
>
> I am trying to output a table with different column widths. That is, each
> column in the table will have a different column width. It looks like
> pretty printing and parameterizing column widths might do the trick but I
> have not been able to put it together and get it to work.
>
> I have a function that determines the maximum string length for each entry
> in a column, from a transposed/pivoted list of lists/matrix and returns a
> list of those maximums for each column. Now I would like to apply those
> widths to each column as each line is printed.
>
> This is for a simple text file.
>
> Any examples or pointers to examples or docs would be much appreciated.
>
> Regards
>
> --
> You can meet at his location,
> but you better come with cash.
>
> -- Cake
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131127/f391af10/attachment.html>

Posted on the users mailing list.