Manfred Lotz wrote at 12/17/2010 01:58 AM:
[...]
(format t "~,5f" pi)
[...]
Is there anything similar to CL's format in Racket?

It would be nice to have a some special support for decimal-point formatting in Racket's "format". Just the number of decimal places to print would be nice. (Other formatting, such as whitespace padding, is a lot less relevant now that we use HTML and graphics languages rather than ASCII text with fixed-pitch characters for formatting. And I woudn't want CL's "format" -- I recall thinking it was an overpowered minilanguage to be stuffing into a string.)

If nobody steps up to the plate for number formatting, I will make a PLaneT package out of some code in my Racket invoicing setup. This code defines special syntax for defining individual number formatters (for, e.g., printing US dollars and cents in a conventional US style). It's not the end-all-be-all, which is why I haven't PLaneT-ized it already, but it's done what I've needed so far.

(define-syntax %make-number-displayer/macro
 (syntax-rules ()
   ((_ sign
       prefix
       pad-whole-char
       pad-whole-length
       whole-spacers-char
       whole-spacers-interval
       decimal-point
       max-fractional-length
       pad-fractional-char
       pad-fractional-length
       suffix)

--
http://www.neilvandyke.org/
_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/users

Reply via email to