chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug/problems with fmt (was Re: [Chicken-users] Columnar text display


From: Alex Shinn
Subject: Re: Bug/problems with fmt (was Re: [Chicken-users] Columnar text display code?)
Date: Sat, 7 Jul 2007 13:19:34 +0900

Hi,

On 7/7/07, Robin Lee Powell <address@hidden> wrote:

Hoo-boy the problems I've had with fmt.  :(  It seems to be lovely
in general, but it really doesn't want to do what I want, which is:

Thanks for using fmt!  Please be aware this is the very first release
and I'm still working on it.

Unfortunately, fmt hangs on the obvious solution:

(fmt #t
     (join
       (lambda (x) (trim 5 x))
       (string-split "foo foo\nbar bar\n" "\n")
       nl))

That's a bug.  I've fixed it in my repository, and will
probably make a new release this weekend.

In the meantime, you can fix the bug in trim by wrapping
everything in (ellipses "" ...).  Setting an empty string ellipses
won't change the output, it just disables an optimization that
caused the bug.

Regarding columnar, the idea there is to format two or more
unrelated things side-by-side, like the two column format in
newspapers.

What you're doing is tabular formatting - specifically, you
want to format by row, not column.

Since one row is a list of the form (ID Artist Title Bitrate URL),
you might want to format a single row as something like:

 (define (fmt-song ls)
   (match-let (((id artist title bitrate url) ls))
     (cat (fit 3 id) " " (fit 12 artist) " " (fit 12 title) " "
          (fit bitrate 12) " " url)))

FIT forces the output into a fixed width, so if you then JOIN
the rows together:

 (fmt #t (join/suffix fmt-song list-of-songs nl))

all the columns will line up.

--
Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]