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.
Also, assume that there exists a text input stream with alias
textin, a text output stream with alias textout, and
a binary output stream with alias binaryout. Assume that the the
first line of textin contains
<space>x(y, Z).
abort / 0abortabort - aborts execution.break / 0breakbreak - initiates a break loop.deny / 1deny(PredicateIndicator)deny(test/1) - removes all clauses of arity 1 having the functor test.foreach / 2foreach(GoalA, GoalB)GoalA repeatedly and, for each success, calls GoalB once. Succeeds if GoalB succeeds for every successof GoalA. Opaque to cuts occurring either in GoalA or GoalB. (Often used as a form of looping construct.)foreach(test(X), write(X)) - writes 1123.peek / 1peek(Code)peek_code/1) Unify Code with the code for the character that would be accessed by get0/1, without actually extracting the character from the input stream.peek(C) - instantiates C to 32 (the code for space).peek / 2peek(StreamOrAlias, Code)peek_code/2) Unify Code with the code for the character that would be accessed by get0/2 on the same stream, without actually extracting the character from the input stream.peek(textin, C) - instantiates C to 32 (the code for space).read_line / 1read_line(Line)Line with the unread portion of the current line in the current input stream. (Reads a new line if at end-of-line.) read_line(Line) - instantiates Line to '<space>a(b, C).'read_line / 2read_line(StreamOrAlias Line)Line with the unread portion of the current line in the stream / stream whose alias is StreamOrAlias. (Reads a new line if at end-of-line.) read_line(textin, Line) - instantiates Line to '<space>x(y, Z).'reset / 1reset(StreamOrAlias)StreamOrAlias to be not at end. If StreamOrAlias refers to a file reading starts from the beginning again on subsequent operations.reset(textin) - resets stream textin.skipln / 0skiplnget type operation will get the character at the start of the next line.skipln - skips forward in the current input stream, so the next character read in the example stream would be '/'.skipln / 1skipln(StreamOrAlias)StreamOrAlias past the end of the current line. The next get type operation will get the character at the start of the next line.skipln(textin) - skips forward in textin, so that the stream is at end of file.stream / 1stream(Term)Term is a numberstream_property(S, [alias(textin)]), stream(S) - succeeds.stream(1) - fails.stream(a(b)) - fails.stream(A) - fails.throw_error / 1throw_error(Error)Error must be the second argument of a ball of the form error(_, Error) caught by catch/3.throw_error(E) - (Assume catch/3 caught a ball of the form error(_, E) ) rethrows the error that was caught