Next: iklib printing pretty, Up: iklib printing [Index]
Build and return a new string formatted according to the template in the string template and the supplied arguments. The template string contains markers in which the string representation of each argument is placed. The markers include:
~sInstructs the formatter to place the next argument as if the procedure
write has printed it; if the argument contains a string, the
string will be quoted and all quotes and backslashes in the string will
be escaped; similarly, characters will be printed using the #\x
notation.
~aInstructs the formatter to place the next argument as if the procedure
display has printed it; strings and characters are placed as they
are in the output.
~bInstructs the formatter to convert the next argument to its binary (base 2) representation; the argument must be an exact number.
~oSimilar to ~b except that the number is printed in octal (base
8).
~xSimilar to ~b except that the number is printed in hexadecimal
(base 16).
~dOutputs the next argument, which can be an exact or inexact number, in its decimal (base 10) representation.
~~Instructs the formatter to place a tilde character, ~, in the
output without consuming an argument.
~%Instructs the formatter to place a newline character in the output without consuming an argument.
Note that the #b, #o, and #x numeric prefixes are
not added to the output when ~b, ~o, and ~x are
used.
> (format "message: ~s, ~s, and ~s" 'symbol "string" #\c) "message: symbol, \"string\", and #\\c" > (format "message: ~a, ~a, and ~a" 'symbol "string" #\c) "message: symbol, string, and c"
Similar to format except that the output is sent to the
current-output-port instead of being collected in a string.
> (let ([n (+ (expt 2 32) #b11001)])
(printf "~d = #b~b = #x~x\n" n n n))
4294967321 = #b100000000000000000000000000011001 = #x100000019
Similar to printf except that the textual output port to which
the output is sent is specified as the first argument.
Next: iklib printing pretty, Up: iklib printing [Index]