11.3.156 portray_clause/[1,2]

Synopsis

portray_clause(+Clause)

portray_clause(+Stream, +Clause)

Writes Clause to the current output stream. Used by listing/[0,1].

Arguments

Stream
stream_object, must be ground

A valid open Prolog stream, defaults to the current output stream.

Clause
term

Description

The operation used by listing/[0,1]. Clause is written to Stream, in exactly the format in which listing/[0,1] would have written it, including a terminating full-stop.

If you want to print a clause, this is almost certainly the command you want. By design, none of the other term output commands puts a full-stop after the written term. If you are writing a file of facts to be loaded by the Load Predicates, use portray_clause/[1,2], which attempts to ensure that the clauses it writes out can be read in again as clauses.

The output format used by portray_clause/[1,2] and listing/[0,1] has been carefully designed to be clear. We recommend that you use a similar style. In particular, never put a semicolon (disjunction symbol) at the end of a line in Prolog.

Exceptions

Stream errors (see ref-iou-sfh-est).

Examples

     | ?- portray_clause((X:- a -> b ; c)).
     _ :-
             (   a ->
                 b
             ;   c
             ).
     | ?- portray_clause((X:- a -> (b -> c ; d ; e); f)).
     _ :-
             (   a ->
                 (   b ->
                     c
                 ;   d
                 ;   e
                 )
             ;   f
             ).
     | ?- portray_clause((a:-b)).
     a :-
             b.
     | ?- portray_clause((a:-b,c)).
     a :-
             b,
             c.
     | ?- portray_clause((a:-(b,!,c))).
     a :-
             b, !,
             c.

See Also

listing/[0,1], ref-iou-tou.


Send feedback on this subject.