In the examples below, assume the database contains
?- dynamic(test/1). ?- public(test/2). test(1). test(1). % Note that this is asserted 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.
consult / 1
consult(File)
File
to be read as a source program, with every clause in it being asserted into the database as by assertz/1.
consult(demo)
- causes demo.pro
to be read as a source file.display / 1
display(Term)
write_canonical/1)
Writes Term
to the current output stream, without using operator or list notation. Atoms that would need to be quoted to be accepted by read
are quoted.display([2 + 2])
- writes '.'(+(2,
2),
[])
to the current output stream.get / 1
get(Code)
Code.
End of file is represented by a code of -1.get(C)
- instantiates C
to 97
(the code for a).get0 / 1
get0(Code)
get_code/1)
Reads the first character - including whitespace - from the current input stream and unifies its code with Code.
End of file is represented by a code of -1.get0(C)
- instantiates C
to 32
(the code for space).listing / 1
listing(PredicateNameOrIndicator)
listing(test/1)
- lists the four clauses for test/1
to the current output stream.listing(test)
- lists the four clauses for test/1
and the two clauses for test/2
to the current output stream.name / 2
name(Atom, CodeList)
atom_codes/2
) If Atom
is instantiated, unifies CodeList
with a list of ASCII codes corresponding to the characters in its name. If Atom
is uninstantiated (in which case CodeList
must be instantiated), instantiates Atom
to an atom whose name is the characters whose codes appear in CodeList.
name(abc, L)
- instantiates L
to [
97,
98,
99
].
name(A, [ 97, 98, 99 ])
- instantiates A
to abc.
name(abc, [ 97, 98, 99 ])
- succeeds.not / 1
not Goal
Goal
as if by once/1.
If Goal
succeeds, this predicate fails; if Goal
fails, this predicate succeeds. Not redoable. Opaque to cuts occurring in Goal.
not atom(a)
- fails.not atom(1)
- succeeds.reconsult / 1
reconsult(File)
File
to be read as a source program, with every clause in it being asserted into the database as by assertz/1.
If a declaration or clause appears in File
for a predicate that previously existed, the existing predicate is abolished the first time a declaration or clause for it is seen in File.
reconsult(demo)
- causes demo.pro
to be read as a source file, abolishing any existing predicates declared or defined in it.see / 1
see(File)
File
to become the current input file, opening it if necessary. If File
was already open, reading resumes where it left off previously. If File
is user,
standard input becomes the current input stream.see(demo)
- Causes demo
to become the current input stream.see(user)
- Reverts to standard input being the current input stream.seeing / 1
seeing(File)
File
with the name of the current input stream, or user
if the current input stream is standard input.seeing(F)
- instantiates F
to the name of the current input stream, or user
as appropriate.seen / 0
seen
seen
- reverts to standard input; and if a file was being used as current input, it is closed.skip / 1
skip(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(97)
- skips forward until just after the 'a',
so the next character read in the example stream would be '('.
tab / 1
tab(Amount)
Amount
spaces to the current output stream.tab(3)
- writes three spaces to the current output stream.tell / 1
tell(File)
File
to become the current output file, opening it if necessary. If File
was already open, writing resumes where it left off previously. If File
is user,
standard output becomes the current output stream.tell(demo)
- Causes demo
to become the current output stream.tell(user)
- Reverts to standard output being the current output stream.telling / 1
telling(File)
File
with the name of the current output stream, or user
if the current output stream is standard output.telling(F)
- instantiates F
to the name of the current output stream, or user
as appropriate.told / 0
told
told
- reverts to standard output; and if a file was being used as current output, it is closed.