[plt-scheme] C-style Printf Format Convention?

From: Karl Pflästerer (sigurd at 12move.de)
Date: Wed May 12 11:53:29 EDT 2004

On 12 May 2004, Brent Fulgham <- bfulg at pacbell.net wrote:

> Is there a PLT string format function that works like
> the C printf?

Maybe fprintf but it's very limited.

> My goal is to be able to print a number with an
> arbitrary
> number of digits, regardless of its actual magnitude:

> e.g.,:

> printf("%-10.5d", 1.23);

> => 1.2300

What kind of C is that? d is a format specifier for an signed decimal
integer.  The above is a floating point number. Did you mean:
`printf("%-10.5f", 1.23)'?

You could write a function which does the padding (left or right) if
necessary of the width and the precision.  That shouldn't be too hard.
All the other sophisticated stuff of printf would be much harder to
implement.

IIRC in SLIB (a Scheme library) there is a kind of printf.  I think it
can be used with PLT Scheme (at least a DrScheme.init file exists in
SLIB).



   Karl
-- 
      And has thou slain the Jabberwock?
          Come to my arms, my beamish boy!
      O frabjous day!  Callooh!  Callay!'
          He chortled in his joy.   "Lewis Carroll" "Jabberwocky"



Posted on the users mailing list.