Eduardo Cavazos <[email protected]> writes:

> Is this a bug with fmt? It seems to happen with the 'fmt' in both
> xitomatl and spells.
>
>> (import (xitomatl fmt))
>> (fmt #t (num 0.000004 10 8) nl)
> 0.000003A0
>
>> (import (spells fmt))
>> (fmt #t (num 0.000004 10 8) nl)
> 0.000003A0

Fixed.

fmt 0.7 is now available at:

  http://synthcode.com/scheme/fmt/

This release also addresses a long-time pet peeve of mine -
you can now format exact non-integral rationals to arbitrary
precision.  Rationals provide extended precision, but until
now it was always difficult to see that precision in a
human-readable manner.

Other features include formatting roman numerals, and a
decimal-align formatter for use in outputting numeric
tables.  Example from the docs:

   (define (print-angles x)
     (fmt-join num (list x (sin x) (cos x) (tan x)) " "))

   (fmt #t (decimal-align 5
             (fix 3
               (fmt-join/suffix print-angles (iota 5) nl))))

outputs

   0.000    0.000    1.000    0.000
   1.000    0.842    0.540    1.557
   2.000    0.909   -0.416   -2.185
   3.000    0.141   -0.990   -0.142
   4.000   -0.757   -0.654    1.158

I'm still thinking about how to best implement a tabular
formatter as suggested previously.  The trick is the
existing columnar formatter is meant to be used on-the-fly,
on large or potentially infinite data, whereas determining
the maximum width of each column requires pre-formatting
every cell of the table.  However, something along those
lines will likely be included in a future release.

-- 
Alex

Reply via email to