How to format output using racket
You can use functions from the racket/format
module. For example ~a
:
#lang racket
(require racket/format)
(~a 42
#:align 'right
#:width 4
#:pad-string "0")
returns
"0042"
format
in #!racket
isn't as rich as sprintf
in C languages. A workaroundwould eb to do it yourself:
(require srfi/13)
(string-pad (number->string 23) 4 #\0) ; ==> "0023"