[racket] Filling number

From: heraklea at gmx.de (heraklea at gmx.de)
Date: Fri Sep 28 09:13:58 EDT 2012

Thank you,

I write my first lambda ;o). What about this:
(define string->mformat 
  (lambda (str)
    (lambda (n)
        (lambda (filler)   (if (equal? (string-length str) n)
                          str
                          (((string->mformat (string-append  filler str)) n) filler))))))

It only prepends, but is this style ok??

Yours,

-------- Original-Nachricht --------
> Datum: Thu, 27 Sep 2012 16:26:00 +0200
> Von: Laurent <laurent.orseau at gmail.com>
> An: heraklea at gmx.de
> CC: racket <users at racket-lang.org>
> Betreff: Re: [racket] Filling number

> Hi,
> 
> Looking for a friend of real->decimal-string (which does only partly what
> you want), I see that the nightly builds include a family of value
> formatters like ~a, ~v, etc.
> You probably want ~r, for example:
> > (~r 42 #:min-width 5 #:pad-string "0")
> "00042"
> 
> They have many options that should fit your needs.
> 
> Cheers,
> Laurent
> 
> On Thu, Sep 27, 2012 at 4:11 PM, <heraklea at gmx.de> wrote:
> 
> > Hello friends,
> >
> > I search the docu, but I cannot find how I can fill a number with
> leading
> > zeros or trailing zeros.
> >
> > I am using number->string and would like fill the missing zeros.
> >
> > Yours,
> > ____________________
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >

Posted on the users mailing list.