Scieneer Common Lisp 1.3.9 online documentation

format destination control-string &rest format-arguments[Function]

Provides various facilities for formatting output. The control-string contains a string to be output, possibly with embedded directives, which are flagged with the escape character "~". Directives generally expand into additional text to be output, usually consuming one or more of the format-arguments in the process. A few useful directives are:

~A or ~nA
Prints one argument as if by princ
~S or ~nS
Prints one argument as if by prin1
~D or ~nD
Prints one argument as a decimal integer
~%
Does a terpri
~&
Does a fresh-line

Where n is the width of the field in which the object is printed.

The destination controls where the result will go. If destination is t, then the output is sent to the standard output stream. If it is nil, then the output is returned in a string as the value of the call. Otherwise, destination must be a stream to which the output will be sent.

Example: (format nil "The answer is ~D." 10) => "The answer is 10."

There are many additional capabilities not described here. Consult the manual for details.