[racket] Is there anything like the cl format?

From: Richard Cleis (rcleis at mac.com)
Date: Fri Dec 17 07:41:04 EST 2010

Someone on this list, several years ago, wrote scheme functions that  
were similar to C/printf/formats.  I don't have time to look for the  
files right now, but they might do everything you want.

RAC

On Dec 17, 2010, at 4:30 AM, Manfred Lotz <manfred.lotz at arcor.de> wrote:

> 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
>
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.