Formatted Output

format(Control, Arguments) interprets the Arguments according to the Control string and prints the result on the current output stream. A stream can be specified using format/3.

This is used to produce output like this, either on the current output or on a specified stream:

     | ?- toc(1.5).
     Table of Contents                                               i
     
                                Table of Contents
     
     1. Documentation supplement for Quintus Prolog Release 1.5 ........... 2
     
        1-1 Definition of the term "loaded" ............................... 2
        1-2 Finding all solutions ......................................... 3
        1-3 Searching for a file in a library ............................. 4
        1-4 New Built-in Predicates ....................................... 5
            1-4-1 write_canonical (?Term) ................................. 5
                         .
                         .
                         .
        1-7 File Specifications .......................................... 17
            1-7-1 multifile(+PredSpec) ................................... 18
     
     yes
     

For details, including the code to produce this example, see the example program in the reference page for format/[2,3]. The character escaping facility is also used.