Jens answered your question, but I'll note two convenient shorthands:

> #lang racket
> (require racket/format)

racket/format is provided by #lang racket, so you can skip that.

This:

(define fp
  (lambda (s n)
    (string-append (pp_number n) " + " s)))

is the same as this:

(define (fp s n)
    (string-append (pp_number n) " + " s)))



On Tue, Dec 14, 2021 at 1:48 PM Cyrille DEUSS <[email protected]>
wrote:

> #lang racket
> (require racket/format)
>
> (define pp_number
>   (lambda (n)
>      (~a n #:width 6 #:align 'right  #:left-pad-string "0")))
>
> (define fp
>   (lambda (s n)
>     (string-append (pp_number n) " + " s)))
>
> (define f
>   (lambda (s n)
>     (format "~a + ~a" n s)))
>
> (foldl f "" '(1 2 3))
> ; works great !
>
> (foldl fp "" '(1 2 3))
> ; and why not this one ?
>
> Thanks in advance.
> Cyrille
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/e72b954e-0b48-4830-b253-34b904d726bcn%40googlegroups.com
> <https://groups.google.com/d/msgid/racket-users/e72b954e-0b48-4830-b253-34b904d726bcn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKoeiVYvsCFuJgHYvK9Eg7cDpSTAkGpk4h2x8aNoe8YHOzg%40mail.gmail.com.

Reply via email to