In the examples below, assume the database contains
?- dynamic(test/1). ?- public(test/2). test(1). test(1). % Note that this is defined twice test(2) :- atom(a). test(3). test(a, b). test(a, c).
Also, assume that the standard input stream will yield the following when read
(where <space>
stands for a single space).
<space>a(b, C). /* This is a comment */ abc.
Also, assume that there exists a text input stream with alias
textin
and a text output stream with alias textout
.
Assume that the the first line of textin
contains
<space>x(y, Z).
display / 2
display(StreamOrAlias, Term)
write_canonical/2)
Writes Term
to the stream / stream having alias StreamOrAlias,
without using operator or list notation. Atoms that would need to be quoted to be accepted by read
are quoted.display(textout, [2 + 2])
- writes '.'(+(2,
2),
[])
to textout.
get / 2
get(StreamOrAlias, Code)
StreamOrAlias
- skipping over whitespace - and unifies its code with Code.
End of file is represented by a code of -1.get(textin, C)
- instantiates C
to 47
(the code for /).get0 / 2
get0(StreamOrAlias, Code)
get_code/2)
Reads the first character - including whitespace - from the stream / stream having alias StreamOrAlias
and unifies its code with Code.
End of file is represented by a code of -1.get0(textin, C)
- instantiates C
to 32
(the code for space).listing / 2
listing(StreamOrAlias, PredicateNameOrIndicator)
StreamOrAlias
listing(textout, test/1)
- lists the four clauses for test/1
to textout.
listing(textout, test)
- lists the four clauses for test/1
and the two clauses for test/2
to textout.
put / 2
put(StreamOrAlias, Code)
put_code/2)
Writes the character whose ASCII code is Code
to the stream / stream having alias StreamOrAlias.
put(textout, 65)
- writes A
to textout.
skip / 2
skip(StreamOrAlias, Code)
StreamOrAlias
until a character with code Code
is read. The next get
type operation will get the character just after this one. End of file is represented by a code of -1.skip(textin, 48)
- skips forward in textin
until just after the '(',
so the next character read in the example stream would be 'x'.
tab / 2
tab(StreamOrAlias, Amount)
Amount
spaces to the stream / stream having alias StreamOrAlias.
tab(textout, 3)
- writes three spaces to textout.