Skip to content

18 Basic Printers

Basic functions to print data

To use the bindings from this module:

(import :std/text/basic-printers)

18.1 write-n-chars

(write-n-chars n char port) -> unspecified

Write character char n times to the port.

Examples:

> (call-with-output-string [] (cut write-n-chars 7 #\a <>))
"aaaaaaa"

18.2 display-integer/base

(display-integer/base integer base (output #t)) -> string or unspecified

Display the integer to the designated output as per with-output, in the designated base. Return the results a string if output is #f, otherwise the function is called for effects and results are unspecified.

Examples:

> (begin (display-integer/base 100 16) (newline))
64
> (display-integer/base 884 36 #f)
"ok"

18.3 display-integer/fit

(display-integer/fit n width (out #t) base: (base 10)) -> string

Display the integer to the designated output as per with-output, in the designated base. Return the results a string if output is #f, otherwise the function is called for effects and results are unspecified.

Examples:

> (display-integer/fit 3 5 #f)
"00003"
> (begin (display-integer/fit 0 5) (newline))
00000
> (display-integer/fit -3 5 #f)
"-0003"
> (display-integer/fit 7 0)
*** ERROR
> (display-integer/fit 7 -1 #f)
*** ERROR
> (display-integer/fit 12345 5 #f)
"12345"
> (display-integer/fit 123456 5)
*** ERROR
> (display-integer/fit 100 2 #f base:16)
"64"