[racket] Is there anything like the cl format?

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Fri Dec 17 06:30:02 EST 2010

On Fri, 17 Dec 2010 11:09:04 +0100
Laurent <laurent.orseau at gmail.com> wrote:

> You probably want
> `real->decimal-string<http://docs.racket-lang.org/reference/generic-numbers.html?q=real&q=number#%28def._%28%28lib._racket/private/base..rkt%29._real-%7E3edecimal-string%29%29>
> '
> 
> Maybe it would be a good idea in the `format' page to add a pointer
> to that function?
> 

Yeah, I used it. However, it isn't nice to code, and it is not quite
the same. 

Compare

; if it were available
(printf "Total:  %4.2f/%2.2f   %4.2f/%2.2f\n" fnum1 fnum2 fnum3 fnum4)  

to this:
(let ([pfnum1 (real->decimal-string fnum1 2)]
      [pfnum2 (real->decimal-string fnum2 2)]
      [pfnum3 (real->decimal-string fnum3 2)]
      [pfnum4 (real->decimal-string fnum4 2)])
  (printf "Total: ~a/~a  ~a/~a" pfnum1 pfnum2 pfnum3 pfnum4))


-- 
Manfred





Posted on the users mailing list.