chickadee » srfi-135 » textual-pad

(textual-pad textual len [char start end]) → textprocedure
(textual-pad-right textual len [char start end]) → textprocedure

Returns a text of length len comprised of the characters drawn from the given subrange of textual, padded on the left (right) by as many occurrences of the character char as needed. If textual has more than len chars, it is truncated on the left (right) to length len. char defaults to #\space.

If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, the result shares storage with that text whenever sharing would be space-efficient.

(textual-pad "325" 5) ⇒ «  325»
(textual-pad "71325" 5) ⇒ «71325»
(textual-pad "8871325" 5) ⇒ «71325»