8.16.0.4
left-pad
(require left-pad) | package: left-pad |
Examples:
> (require left-pad) > (left-pad "foo" 5) " foo"
> (left-pad "foobar" 6) "foobar"
> (left-pad 17 5 0) "00017"
procedure
(left-pad value pad-width [pad-value]) → string?
value : any/c pad-width : exact-positive-integer? pad-value : " " = any/c
Converts value to a string in display mode, then pads it with copies of pad-value (after coercing pad-value to a string) until the result has length pad-width.
Returns the same result as:
(~a value #:align 'right #:min-width pad-width #:left-pad-string (~a pad-value))
except that it can be faster (or slower — it’s currently slower).
The preconditions of left-pad are:
The postconditions of left-pad are:
The pre- and post-conditions are enforced by a badass dependent contract.
1 Typed Racket API
(require left-pad/typed) | package: left-pad |
value
left-pad : (->* [Any Integer] [Any] String)