These variables are defined in the global environment. They control the maximum length and maximum depth, respectively, of a list or vector that is printed. If one of the variables is not bound to an integer, or if its value exceeds a certain, large maximum value (which is at least 2^20), a default value is taken. The default value for print-length is 1000, and the default value for print-depth is 20. Negative values of print-length and print-depth are treated as ``unlimited'', i.e. output is not truncated.
(write obj output-port)
(display obj output-port)
(write-char char output-port)
(print obj output-port)
If the second argument is omitted, it defaults to the current output port.
Prints obj using write and then prints a newline. print returns void.
(format destination format-string obj ...)
Prints the third and the following arguments according to the specifications in the string format-string. Characters from the format string are copied to the output. When a tilde is encountered in the format string, the tilde and the immediately following character are replaced in the output as follows:
An error is signaled if fewer objs are provided than required by the given format string. If the format string ends in a tilde, the tilde is ignored.
If destination is #t, the output is sent to the current
output port; if #f is given, the output is returned as a string;
otherwise, destination must be an output or input-output port.
(format #f "Hello world!") ==> "Hello world" (format #f "~s world!" "Hello") ==> "\"Hello\" world" (format #f "~a world!" "Hello") ==> "Hello world" (format #f "Hello~a") ==> "Hello!"
(define (flat-size s) (fluid-let ((print-length 1000) (print-depth 100)) (string-length (format #f "~a" s))))
(flat-size 1.5) ==> 3 (flat-size '(a b c)) ==> 7