GNU PROLOG
A Native Prolog Compiler with Constraint Solving over Finite Domains Edition 1.8, for GNU Prolog version 1.3.0 5th January, 2007 by Daniel Diaz |
% gprolog [OPTION]... | (the % symbol is the operating system shell prompt) |
–init-goal GOAL | execute GOAL before top_level/0 |
–entry-goal GOAL | execute GOAL inside top_level/0 |
–query-goal GOAL | execute GOAL as a query for top_level/0 |
–help | print a help and exit |
–version | print version number and exit |
– | do not parse the rest of the command-line |
GNU Prolog 1.2.9 By Daniel Diaz Copyright (C) 1999-2007 Daniel Diaz | ?-
before GNU Prolog 1.2.9 By Daniel Diaz Copyright (C) 1999-2007 Daniel Diaz inside | ?- append([a,b],[c,d],X). X = [a,b,c,d] yes | ?-
| ?- append(X,Y,[a,b,c]). | ||
X = [] | ||
Y = [a,b,c] ? ; | (here the user presses ; to compute another solution) | |
X = [a] | ||
Y = [b,c] ? a | (here the user presses a to compute all remaining solutions) | |
X = [a,b] | ||
Y = [c] | (here the user is not asked and the next solution is computed) | |
X = [a,b,c] | ||
Y = [] | (here the user is not asked and the next solution is computed) | |
no | (no more solution) |
| ?- (X=1 ; X=2). | ||
X = 1 ? ; | (here the user presses ; to compute another solution) | |
X = 2 | (here the user is not prompted since there are no more alternatives) | |
yes |
| ?- (X=1 ; X=2). | ||
X = 1 ? | (here the user presses RETURN to stop the execution) | |
yes |
| ?- X=f(A,B,_,A), A=k. | ||
A = k | (the value of A is displayed also in f/3 for X) | |
X = f(k,B,_,k) | (since B is a variable which is also a part of X, B is not displayed) |
| ?- functor(T,f,3), arg(1,T,X), arg(3,T,X). | ||
T = f(X,_,X) | (the 1st and 3rd args are equal to X, the 2nd is an anonymous variable) |
| ?- read_from_atom('k(X,Y,X).',T). | ||
T = k(A,_,A) | (the 1st and 3rd args are unified, a new variable name A is introduced) |
| ?- X='$VARNAME'('Y'), Y='$VAR'(1). | ||
X = Y | (the term '$VARNAME'('Y') is displayed as Y) | |
Y = '$VAR'(1) | (the term '$VAR'(1) is displayed as is) |
| ?- X=Y, Y='$VAR'(1). | ||
X = '$VAR'(1) | ||
Y = '$VAR'(1) |
| ?- retractall(p(_)), assertz(p(0)), | ||
repeat, | ||
retract(p(X)), | ||
Y is X + 1, | ||
assertz(p(Y)), | ||
X = 1000, !. | ||
X = 1000 | ||
Y = 1001 | ||
(180 ms) yes | (the query took 180ms of user time) |
| ?- [user]. | ||
{compiling user for byte code...} | ||
even(0). | ||
even(s(s(X))):- | ||
even(X). | ||
(here the user presses Ctl-D to end the input) | ||
{user compiled, 3 lines read - 350 bytes written, 1180 ms} | ||
| ?- even(X). | ||
X = 0 ? ; | (here the user presses ; to compute another solution) | |
X = s(s(0)) ? ; | (here the user presses ; to compute another solution) | |
X = s(s(s(s(0)))) ? | (here the user presses RETURN to stop the execution) | |
yes | ||
| ?- listing. | ||
even(0). | ||
even(s(s(A))) :- | ||
even(A). |
Command | Name | Description |
a | abort | abort the current execution. Same as abort/0 (section 7.18.1) |
e | exit | quit the current Prolog process. Same as halt/0 (section 7.18.1) |
b | break | invoke a recursive top-level. Same as break/0 (section 7.18.1) |
c | continue | resume the execution |
t | trace | start the debugger using trace/0 (section 4.3.1) |
d | debug | start the debugger using debug/0 (section 4.3.1) |
h or ? | help | display a summary of available commands |
Key | Alternate key | Description |
Ctl-B | ← | go to the previous character |
Ctl-F | → | go to the next character |
Esc-B | Ctl-← | go to the previous word |
Esc-F | Ctl-→ | go to the next word |
Ctl-A | Home | go to the beginning of the line |
Ctl-E | End | go to the end of the line |
Ctl-H | Backspace | delete the previous character |
Ctl-D | Delete | delete the current character |
Ctl-U | Ctl-Home | delete from beginning of the line to the current character |
Ctl-K | Ctl-End | delete from the current character to the end of the line |
Esc-L | lower case the next word | |
Esc-U | upper case the next word | |
Esc-C | capitalize the next word | |
Ctl-T | exchange last two characters | |
Ctl-V | Insert | switch on/off the insert/replace mode |
Ctl-I | Tab | complete word (twice displays all possible completions) |
Esc-Ctl-I | Esc-Tab | insert spaces to emulate a tabulation |
Ctl-space | mark beginning of the selection | |
Esc-W | copy (from the begin selection mark to the current character) | |
Ctl-W | cut (from the begin selection mark to the current character) | |
Ctl-Y | paste | |
Ctl-P | ↑ | recall previous history line |
Ctl-N | ↓ | recall next history line |
Esc-P | recall previous history line beginning with the current prefix | |
Esc-N | recall next history line beginning with the current prefix | |
Esc-< | Page Up | recall first history line |
Esc-> | Page Down | recall last history line |
Ctl-C | generate an interrupt signal (section 3.2.4) | |
Ctl-D | generate an end-of-file character (at the begin of the line) | |
RETURN | validate a line | |
Esc-? | display a summary of available commands |
| ?- argu | (here the user presses Tab to complete the word) | |
| ?- argument_ | (linedit completes argu with argument_ and emits a beep) | |
(the user presses again Tab to see all possible completions) | ||
argument_counter | (linedit shows 3 possible completions) | |
argument_list | ||
argument_value | ||
| ?- argument_ | (linedit redisplays the input line) | |
| ?- argument_c | (to select argument_counter the user presses c and Tab) | |
| ?- argument_counter | (linedit completes with argument_counter) |
Stack | Default | Environment | Description |
name | size (Kb) | variable | |
local | 4096 | LOCALSZ | control stack (environments and choice-points) |
global | 8192 | GLOBALSZ | heap (compound terms) |
trail | 3072 | TRAILSZ | conditional bindings (bindings to undo at backtracking) |
cstr | 3072 | CSTRSZ | finite domain constraint stack (FD variables and constraints) |
LOCALSZ=8192; export LOCALS | (under sh or bash) | |
setenv LOCALSZ 8192 | (under csh or tcsh) |
Type | Speed | Debug ? | For what |
interpreted-code | slow | yes | meta-call and dynamically asserted clauses |
byte-code | medium | yes | consulted predicates |
native-code | fast | no | compiled predicates |
Suffix of the file | Type of the file | Handled by: |
.pl, .pro | Prolog source file | pl2wam |
.wam | WAM source file | wam2ma |
.ma | Mini-assembly source file | ma2asm |
.s | Assembly source file | the assembler |
.c, .C, .CC, .cc, .cxx, .c++, .cpp | C or C++ source file | the C compiler |
.fd | Finite Domain constraint source file | fd2c |
any other suffix (.o, .a,...) | any other type (object, library,...) | the linker (C linker) |
% gplc [OPTION]... FILE... | (the % symbol is the operating system shell prompt) |
-o FILE, –output FILE | use FILE as the name of the output file |
-W, –wam-for-native | stop after producing WAM files(s) |
-w, –wam-for-byte-code | stop after producing WAM for byte-code file(s) (force –no-call-c) |
-M, –mini-assembly | stop after producing mini-assembly files(s) |
-S, –assembly | stop after producing assembly files (s) |
-F, –fd-to-c | stop after producing C files(s) from FD constraint definition file(s) |
-c, –object | stop after producing object files(s) |
–temp-dir PATH | use PATH as directory for temporary files |
–no-del-temp | do not delete temporary files |
–no-decode-hexa | do not decode hexadecimal predicate names |
-v, –verbose | print executed commands |
-h, –help | print a help and exit |
–version | print version number and exit |
–pl-state FILE | read FILE to set the initial Prolog state |
–no-susp-warn | do not show warnings for suspicious predicates |
–no-singl-warn | do not show warnings for named singleton variables |
–no-redef-error | no not show errors for built-in predicate redefinitions |
–foreign-only | only compile foreign/1-2 directives |
–no-call-c | do not allow the use of fd_tell, '$call_c',... |
–no-inline | do not inline predicates |
–no-reorder | do not reorder predicate arguments |
–no-reg-opt | do not optimize registers |
–min-reg-opt | minimally optimize registers |
–no-opt-last-subterm | do not optimize last subterm compilation |
–fast-math | use fast mathematical mode (assume integer arithmetics) |
–keep-void-inst | keep void WAM instructions in the output file |
–compile-msg | print a compile message |
–statistics | print statistics information |
–comment | include comments in the output file |
–comment | include comments in the output file |
–c-compiler FILE | use FILE as C compiler |
-C OPTION | pass OPTION to the C compiler |
-A OPTION | pass OPTION to the assembler |
–local-size N | set default local stack size to N Kb |
–global-size N | set default global stack size to N Kb |
–trail-size N | set default trail stack size to N Kb |
–cstr-size N | set default constraint stack size to N Kb |
–fixed-sizes | do not consult environment variables at run-time (use default sizes) |
–no-top-level | do not link the top-level (force –no-debugger) |
–no-debugger | do not link the Prolog/WAM debugger |
–min-pl-bips | link only used Prolog built-in predicates |
–min-fd-bips | link only used FD solver built-in predicates |
–min-bips | shorthand for: –no-top-level –min-pl-bips –min-fd-bips |
–min-size | shorthand˛ for: –min-bips –strip |
–no-fd-lib | do not look for the FD library (maintenance only) |
-s, –strip | strip the executable |
-L OPTION | Pass OPTION to the linker |
% gplc -W prog.pl % gplc -M --comment prog.wam % gplc -S --comment prog.ma % gplc -c prog.s % gplc -o prog -s prog.o
% gplc --no-top-level prog.pl % prog Warning: no initial goal executed use a directive :- initialization(Goal) or remove the link option --no-top-level (or --min-bips or --min-size)
% hexgplc [OPTION]... FILE... | (the % symbol is the operating system shell prompt) |
–encode | encoding mode (default mode is decoding) |
–relax | decode also predicate names (not only predicate indicators) |
–printf FORMAT | pass encoded/decoded string to C printf(3) with FORMAT |
–aux-father | decode an auxiliary predicate as its father |
–aux-father2 | decode an auxiliary predicate as its father + auxiliary number |
–cmd-line | encode/decode each argument of the command-line |
-H | same as: –cmd-line –encode |
-P | same as: –cmd-line –relax |
–help | print a help and exit |
–version | print version number and exit |
% hexgplc -H 'x+y=z' X782B793D7A
Command | Name | Description |
RET or c | creep | single-step to the next port |
l | leap | continue the execution only stopping when a goal with a spy-point is reached |
s | skip | skip over the entire execution of the current goal. No message will be shown until control returns |
G | go to | ask for an invocation number and continue the execution until a port is reached for that invocation number |
r | retry | try to restart the invocation of the current goal by failing until reaching the invocation of the goal. The state of execution is the same as when the goal was initially invoked (except when using side-effect predicates) |
f | fail | force the current goal to fail immediately |
w | write | show the current goal using write/2 (section 7.14.6) |
d | display | show the current goal using display/2 (section 7.14.6) |
p | show the current goal using print/2 (section 7.14.6) | |
e | exception | show the pending exception. Only applicable to an exception port |
g | ancestors | show the list of ancestors of the current goal |
A | alternatives | show the list of ancestors of the current goal combined with choice-points |
u | unify | ask for a term and unify the current goal with this term. This is convenient for getting a specific solution. Only available at a call port |
. | father file | show the Prolog file name and the line number where the current predicate is defined |
n | no debug | switch the debugger off. Same as nodebug/0 (section 4.3.1) |
= | debugging | show debugger information. Same as debugging/0 (section 4.3.1) |
+ | spy this | set a spy-point on the current goal. Uses spy/1 (section 4.3.3) |
- | nospy this | remove a spy-point on the current goal. Uses nospy/1 (section 4.3.3) |
* | spy conditionally | ask for a term Goal, Port, Test (terminated by a dot) and set a conditional spy-point on the current predicate. Goal and the current goal must have the same predicate indicator. Uses spypoint_condition/3 (section 4.3.3) |
L | listing | list all the clauses associated with the current predicate. Uses listing/1 (section 7.23.3) |
a | abort | abort the current execution. Same as abort/0 (section 7.18.1) |
b | break | invoke a recursive top-level. Same as break/0 (section 7.18.1) |
@ | execute goal | ask for a goal and execute it |
< | set print depth | ask for an integer and set the print depth to this value (-1 for no depth limit) |
h or ? | help | display a summary of available commands |
W | WAM debugger | invoke the low-level WAM debugger (section 4.6) |
Command | Description |
write A [N] | write N terms starting at the address A using write/1 (section 7.14.6) |
data A [N] | display N words starting at the address A |
modify A [N] | display and modify N words starting at the address A |
where A | display the real address corresponding to A |
what RA | display what corresponds to the real address RA |
deref A | display the dereferenced word starting at the address A |
envir [SA] | display the contents of the environment located at SA (or the current one) |
backtrack [SA] | display the contents of the choice-point located at SA (or the current one) |
backtrack all | display all choice-points |
quit | quit the WAM debugger |
help | display a summary of available commands |
Type | Description |
TYPE_list | a list whose the type of each element is TYPE |
TYPE1_or_TYPE2 | a term whose type is either TYPE1 or TYPE2 |
atom | an atom |
atom_property | an atom property (section 7.19.12) |
boolean | the atom true or false |
byte | an integer ≥ 0 and ≤ 255 |
callable_term | an atom or a compound term |
character | a single character atom |
character_code | an integer ≥ 1 and ≤ 255 |
clause | a clause (fact or rule) |
close_option | a close option (section 7.10.7) |
compound_term | a compound term |
evaluable | an arithmetic expression (section 7.6.1) |
fd_bool_evaluable | a boolean FD expression (section 8.7.1) |
fd_labeling_option | an FD labeling option (section 8.9.1) |
fd_evaluable | an arithmetic FD expression (section 8.6.1) |
fd_variable | an FD variable |
flag | a Prolog flag (section 7.22.1) |
float | a floating point number |
head | a head of a clause (atom or compound term) |
integer | an integer |
in_byte | an integer ≥ 0 and ≤ 255 or -1 (for the end-of-file) |
in_character | a single character atom or the atom end_of_file (for the end-of-file) |
in_character_code | an integer ≥ 1 and ≤ 255 or -1 (for the end-of-file) |
io_mode | an atom in: read, write or append |
list | the empty list [] or a non-empty list [_|_] |
nonvar | any term that is not a variable |
number | an integer or a floating point number |
operator_specifier | an operator specifier (section 7.14.10) |
os_file_property | an operating system file property (section 7.27.11) |
predicate_indicator | a term Name/Arity where Name is an atom and Arity an integer ≥ 0. A callable term can be given if the strict_iso Prolog flag is switched off (section 7.22.1) |
predicate_property | a predicate property (section 7.8.2) |
read_option | a read option (section 7.14.1) |
socket_address | a term of the form 'AF_UNIX'(A) or 'AF_INET'(A,N) where A is an atom and N an integer |
socket_domain | an atom in: 'AF_UNIX' or 'AF_INET' |
source_sink | an atom identifying a source or a sink |
stream | a stream-term: a term of the form '$stream'(N) where N is an integer ≥ 0 |
stream_option | a stream option (section 7.10.6) |
stream_or_alias | a stream-term or an alias (atom) |
stream_position | a stream position: a term '$stream_position'(I1, I2, I3, I4) where I1, I2, I3 and I4 are integers |
stream_property | a stream property (section 7.10.10) |
stream_seek_method | an atom in: bof, current or eof |
term | any term |
var_binding_option | a variable binding option (section 7.5.3) |
write_option | a write option (section 7.14.6) |
my_pred(X) :- ( nonvar(X) -> true ; throw(error(instantiation_error), my_pred/1)), ), ( integer(X) -> true ; throw(error(type_error(integer, X), my_pred/1)) ), ...
my_pred(X) :- set_bip_name(my_pred,1), ( nonvar(X) -> true ; '$pl_err_instantiation' ), ( integer(X) -> true ; '$pl_err_type'(integer, X) ), ...
Goal1 or Goal2 is a variable | instantiation_error | ||
Goal1 is neither a variable nor a callable term | type_error(callable, Goal1) | ||
Goal2 is neither a variable nor a callable term | type_error(callable, Goal2) | ||
The predicate indicator Pred of Goal1 or Goal2 does not correspond to an existing procedure and the value of the unknown Prolog flag is error (section 7.22.1) | existence_error(procedure, Pred) | ||
Goal is a variable | instantiation_error | ||
Goal is neither a variable nor a callable term | type_error(callable, Goal) | ||
The predicate indicator Pred of Goal does not correspond to an existing procedure and the value of the unknown Prolog flag is error (section 7.22.1) | existence_error(procedure, Pred) | ||
Goal is a variable | instantiation_error | ||
Goal is neither a variable nor a callable term | type_error(callable, Goal) | ||
The predicate indicator Pred of Goal does not correspond to an existing procedure and the value of the unknown Prolog flag is error (section 7.22.1) | existence_error(procedure, Pred) | ||
Ball is a variable | instantiation_error | ||
Result is neither a variable nor an atom | type_error(atom, Result) | ||
Term and Name are both variables | instantiation_error | ||
Term and Arity are both variables | instantiation_error | ||
Term is a variable and Name is neither a variable nor an atomic term | type_error(atomic, Name) | ||
Term is a variable and Arity is neither a variable nor an integer | type_error(integer, Arity) | ||
Term is a variable, Name is a constant but not an atom and Arity is an integer > 0 | type_error(atom, Name) | ||
Term is a variable and Arity is an integer > max_arity flag (section 7.22.1) | representation_error(max_arity) | ||
Term is a variable and Arity is an integer < 0 | domain_error(not_less_than_zero, Arity) | ||
N is a variable | instantiation_error | ||
Term is a variable | instantiation_error | ||
N is neither a variable nor an integer | type_error(integer, N) | ||
Term is neither a variable nor a compound term | type_error(compound, Term) | ||
N is an integer < 0 | domain_error(not_less_than_zero, N) | ||
Term is a variable and List is a partial list | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
Term is a variable and List is a list whose head is a variable | instantiation_error | ||
List is a list whose head H is neither an atom nor a variable and whose tail is not the empty list | type_error(atom, H) | ||
List is a list whose head H is a compound term and whose tail is the empty list | type_error(atomic, H) | ||
Term is a variable and List is the empty list | domain_error(non_empty_list, []) | ||
Term is a variable and the tail of List has a length > max_arity flag (section 7.22.1) | representation_error(max_arity) | ||
N is a variable | instantiation_error | ||
N is neither a variable nor an integer | type_error(integer, N) | ||
N is an integer < 0 | domain_error(not_less_than_zero, N) | ||
Term is a variable | instantiation_error | ||
Term is neither a variable nor a compound term | type_error(compound, Term) | ||
NewValue is neither an atom nor an integer and Undo = false | type_error(atomic, NewValue) | ||
Undo is a variable | instantiation_error | ||
Undo is neither a variable nor a boolean | type_error(boolean, Undo) | ||
List is a partial list | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
Rest is neither a partial list nor a list | type_error(list, Rest) | ||
Options is a partial list or a list with an element E which is a variable | instantiation_error | ||
Options is neither a partial list nor a list | type_error(list, Options) | ||
an element E of the Options list is neither a variable nor a variable binding option | domain_error(var_binding_option, E) | ||
From is a variable | instantiation_error | ||
From is neither a variable nor an integer | type_error(integer, From) | ||
Next is neither a variable nor an integer | type_error(integer, Next) | ||
List is a partial list | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
Term and Ref are both variables | instantiation_error | ||
Ref is neither a variable nor an integer | type_error(integer, Ref) | ||
Ref is an integer < 0 | domain_error(not_less_than_zero, Ref) | ||
Expression | Result = eval(Expression) |
Signature | ISO |
Variable | must be bound to a non-variable expression E.
The result is eval(E) |
IF → IF | Y |
integer number | this number |
I → I | Y |
floating point number | this number |
F → F | Y |
+ E | eval(E) |
IF → IF | N |
- E | - eval(E) |
IF → IF | Y |
inc(E) | eval(E) + 1 |
IF → IF | N |
dec(E) | eval(E) - 1 |
IF → IF | N |
E1 + E2 | eval(E1) + eval(E2) |
IF, IF → IF | Y |
E1 - E2 | eval(E1) - eval(E2) |
IF, IF → IF | Y |
E1 * E2 | eval(E1) * eval(E2) |
IF, IF → IF | Y |
E1 / E2 | eval(E1) / eval(E2) |
IF, IF → F | Y |
E1 // E2 | rnd(eval(E1) /
eval(E2)) |
I, I → I | Y |
E1 rem E2 | eval(E1) -
(rnd(eval(E1) /
eval(E2))*eval(E2)) |
I, I → I | Y |
E1 mod E2 | eval(E1) - (
⌊eval(E1) / eval(E2)⌋
*eval(E2)) |
I, I → I | Y |
E1 /\ E2 | eval(E1) bitwise_and
eval(E2) |
I, I → I | Y |
E1 \/ E2 | eval(E1) bitwise_or
eval(E2) |
I, I → I | Y |
E1 ^ E2 | eval(E1) bitwise_xor
eval(E2) |
I, I → I | N |
\ E | bitwise_not eval(E) |
I → I | Y |
E1 << E2 | eval(E1) integer_shift_left
eval(E2) |
I, I → I | Y |
E1 >> E2 | eval(E1) integer_shift_right
eval(E2) |
I, I → I | Y |
abs(E) | absolute value of eval(E) |
IF → IF | Y |
sign(E) | sign of eval(E) (-1 if < 0, 0 if = 0,
+1 if > 0) |
IF → IF | Y |
min(E1,E2) | minimal value between eval(E1) and
eval(E2) |
IF, IF → ? | N |
max(E1,E2) | maximal value between eval(E1) and
eval(E2) |
IF, IF → ? | N |
E1 ** E2 | eval(E1) raised to the power of
eval(E2) |
IF, IF → F | Y |
sqrt(E) | square root of eval(E) |
IF → F | Y |
atan(E) | arc tangent of eval(E) |
IF → F | Y |
cos(E) | cosine of eval(E) |
IF → F | Y |
acos(E) | arc cosine of eval(E) |
IF → F | N |
sin(E) | sine of eval(E) |
IF → F | Y |
asin(E) | arc sine of eval(E) |
IF → F | N |
exp(E) | e raised to the power of eval(E) |
IF → F | Y |
log(E) | natural logarithms of eval(E) |
IF → F | Y |
float(E) | the floating point number equal to
eval(E) |
IF → F | Y |
ceiling(E) | rounds eval(E) upward to the
nearest integer |
F → I | Y |
floor(E) | rounds eval(E) downward to the
nearest integer |
F → I | Y |
round(E) | rounds eval(E) to the nearest integer |
F → I | Y |
truncate(E) | the integer value of eval(E) |
F → I | Y |
float_fractional_part(E) | the float equal to the fractional part
of eval(E) |
F → F | Y |
float_integer_part(E) | the float equal to the integer part of
eval(E) |
F → F | Y |
a sub-expression E is a variable | instantiation_error | ||
a sub-expression E is neither a number nor an evaluable functor | type_error(evaluable, E) | ||
a sub-expression E is a floating point number while an integer is expected | type_error(integer, E) | ||
a sub-expression E is an integer while a floating point number is expected | type_error(float, E) | ||
a division by zero occurs | evaluation_error(zero_divisor) | ||
Head is a variable | instantiation_error | ||
Head is neither a variable nor a callable term | type_error(callable, Head) | ||
Body cannot be converted to a goal | type_error(callable, Body) | ||
The predicate indicator Pred of Head is that of a static procedure | permission_error(modify, static_procedure, Pred) | ||
Head is a variable | instantiation_error | ||
Head is neither a variable nor a callable term | type_error(callable, Head) | ||
The predicate indicator Pred of Head is that of a static procedure | permission_error(modify, static_procedure, Pred) | ||
Head is a variable | instantiation_error | ||
Head is not a callable term | type_error(callable, Head) | ||
The predicate indicator Pred of Head is that of a static procedure | permission_error(modify, static_procedure, Pred) | ||
Head is a variable | instantiation_error | ||
Head is neither a variable nor a callable term | type_error(callable, Head) | ||
The predicate indicator Pred of Head is that of a private procedure | permission_error(access, private_procedure, Pred) | ||
Body is neither a variable nor a callable term | type_error(callable, Body) | ||
Pred is a variable | instantiation_error | ||
Pred is a term Name/Arity and either Name or Arity is a variable | instantiation_error | ||
Pred is neither a variable nor a predicate indicator | type_error(predicate_indicator, Pred) | ||
Pred is a term Name/Arity and Arity is neither a variable nor an integer | type_error(integer, Arity) | ||
Pred is a term Name/Arity and Name is neither a variable nor an atom | type_error(atom, Name) | ||
Pred is a term Name/Arity and Arity is an integer < 0 | domain_error(not_less_than_zero, Arity) | ||
Pred is a term Name/Arity and Arity is an integer > max_arity flag (section 7.22.1) | representation_error(max_arity) | ||
The predicate indicator Pred is that of a static procedure | permission_error(modify, static_procedure, Pred) | ||
Pred is neither a variable nor a predicate indicator | type_error(predicate_indicator, Pred) | ||
Pred is a term Name/Arity and Arity is neither a variable nor an integer | type_error(integer, Arity) | ||
Pred is a term Name/Arity and Name is neither a variable nor an atom | type_error(atom, Name) | ||
Pred is a term Name/Arity and Arity is an integer < 0 | domain_error(not_less_than_zero, Arity) | ||
Pred is a term Name/Arity and Arity is an integer > max_arity flag (section 7.22.1) | representation_error(max_arity) | ||
Pred is neither a variable nor a predicate indicator | type_error(predicate_indicator, Pred) | ||
Pred is a term Name/Arity and Arity is neither a variable nor an integer | type_error(integer, Arity) | ||
Pred is a term Name/Arity and Name is neither a variable nor an atom | type_error(atom, Name) | ||
Pred is a term Name/Arity and Arity is an integer < 0 | domain_error(not_less_than_zero, Arity) | ||
Pred is a term Name/Arity and Arity is an integer > max_arity flag (section 7.22.1) | representation_error(max_arity) | ||
Property is neither a variable nor a predicate property term | domain_error(predicate_property, Property) | ||
Property = prolog_file(File) and File is neither a variable nor an atom | type_error(atom, File) | ||
Property = prolog_line(Line) and Line is neither a variable nor an integer | type_error(integer, Line) | ||
Goal is a variable | instantiation_error | ||
Goal is neither a variable nor a callable term | type_error(callable, Goal) | ||
The predicate indicator Pred of Goal does not correspond to an existing procedure and the value of the unknown Prolog flag is error (section 7.22.1) | existence_error(procedure, Pred) | ||
Instances is neither a partial list nor a list | type_error(list, Instances) | ||
Goal is a variable | instantiation_error | ||
Goal is neither a variable nor a callable term | type_error(callable, Goal) | ||
The predicate indicator Pred of Goal does not correspond to an existing procedure and the value of the unknown Prolog flag is error (section 7.22.1) | existence_error(procedure, Pred) | ||
Instances is neither a partial list nor a list | type_error(list, Instances) | ||
Stream is neither a variable nor a stream | domain_error(stream, Stream) | ||
Stream is neither a variable nor a stream | domain_error(stream, Stream) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an input stream | permission_error(output, stream, SorA) | ||
SourceSink is a variable | instantiation_error | ||
Mode is a variable | instantiation_error | ||
Options is a partial list or a list with an element E which is a variable | instantiation_error | ||
Mode is neither a variable nor an atom | type_error(atom, Mode) | ||
Options is neither a partial list nor a list | type_error(list, Options) | ||
Stream is not a variable | type_error(variable, Stream) | ||
SourceSink is neither a variable nor a source/sink | domain_error(source_sink, SourceSink) | ||
Mode is an atom but not an input/output mode | domain_error(io_mode, Mode) | ||
an element E of the Options list is neither a variable nor a stream-option | domain_error(stream_option, E) | ||
the source/sink specified by SourceSink does not exist | existence_error(source_sink, SourceSink) | ||
the source/sink specified by SourceSink cannot be opened | permission_error(open, source_sink, SourceSink) | ||
an element E of the Options list is alias(A) and A is already associated with an open stream | permission_error(open, source_sink, alias(A)) | ||
an element E of the Options list is mirror(M) and M is not associated with an open stream | existence_error(stream, M) | ||
an element E of the Options list is mirror(M) and M iis an input stream | permission_error(output, stream, M) | ||
an element E of the Options list is reposition(true) and it is not possible to reposition this stream | permission_error(open, source_sink, reposition(true)) | ||
SorA is a variable | instantiation_error | ||
Options is a partial list or a list with an element E which is a variable | instantiation_error | ||
Options is neither a partial list nor a list | type_error(list, Options) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
an element E of the Options list is neither a variable nor a close-option | domain_error(close_option, E) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA needs a special close (section 7.11) | system_error(needs_special_close) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an input stream | permission_error(output, stream, SorA) | ||
Stream is neither a variable nor a stream-term | domain_error(stream, Stream) | ||
Stream is a variable | instantiation_error | ||
Stream is neither a variable nor a stream-term | domain_error(stream, Stream) | ||
Property is neither a variable nor a stream property | domain_error(stream_property, Property) | ||
Property = file_name(E), mode(E), alias(E), end_of_stream(E), eof_action(E), reposition(E), type(E) or buffering(E) and E is neither a variable nor an atom | type_error(atom, E) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
Position is neither a variable nor a stream-position term | domain_error(stream_position, Position) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Position is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
Position is neither a variable nor a stream-position term | domain_error(stream_position, Position) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA has stream property reposition(false) | permission_error(reposition, stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Whence is a variable | instantiation_error | ||
Offset is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
Whence is neither a variable nor an atom | type_error(atom, Whence) | ||
Whence is an atom but not a valid stream seek method | domain_error(stream_seek_method, Whence) | ||
Offset is neither a variable nor an integer | type_error(integer, Offset) | ||
NewOffset is neither a variable nor an integer | type_error(integer, NewOffset) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA has stream property reposition(false) | permission_error(reposition, stream, SorA) | ||
SorA is associated with a text stream | permission_error(reposition, text_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Count is neither a variable nor an integer | type_error(integer, Count) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Count is neither a variable nor an integer | type_error(integer, Count) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is associated with a binary stream | permission_error(access, binary_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Count is neither a variable nor an integer | type_error(integer, Count) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is associated with a binary stream | permission_error(access, binary_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Line is neither a variable nor an integer | type_error(integer, Line) | ||
Column is neither a variable nor an integer | type_error(integer, Column) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is associated with a binary stream | permission_error(access, binary_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Line is a variable | instantiation_error | ||
Column is a variable | instantiation_error | ||
Line is neither a variable nor an integer | type_error(integer, Line) | ||
Column is neither a variable nor an integer | type_error(integer, Column) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is associated with a binary stream | permission_error(reposition, binary_stream, SorA) | ||
SorA has stream property reposition(false) | permission_error(reposition, stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Alias is a variable | instantiation_error | ||
Alias is neither a variable nor an atom | type_error(atom, Alias) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
Alias is already associated with an open stream | permission_error(add_alias, source_sink, alias(Alias)) | ||
Stream is neither a variable nor a stream-term | domain_error(stream, Stream) | ||
Alias is neither a variable nor an atom | type_error(atom, Alias) | ||
SorA is a variable | instantiation_error | ||
Mirror is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
Mirror is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, Mirror) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
Mirror is not associated with an open stream | existence_error(stream, Mirror) | ||
Mirror is an input stream | permission_error(output, stream, Mirror) | ||
SorA is a variable | instantiation_error | ||
Mirror is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
Mirror is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, Mirror) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
Mirror is not associated with an open stream | existence_error(stream, Mirror) | ||
Stream is neither a variable nor a stream-term | domain_error(stream, Stream) | ||
M is neither a variable nor a stream-term | domain_error(stream, M) | ||
SorA is a variable | instantiation_error | ||
Type is a variable | instantiation_error | ||
Type is neither a variable nor a valid type | domain_error(stream_type, Type) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
An I/O operation has already been executed on SorA | permission_error(modify, stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Action is a variable | instantiation_error | ||
Action is neither a variable nor a valid eof action | domain_error(eof_action, Action) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(modify, stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Buffering is a variable | instantiation_error | ||
Buffering is neither a variable nor a valid buffering mode | domain_error(buffering_mode, Buffering) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
Stream is not a variable | type_error(variable, Stream) | ||
Atom is a variable | instantiation_error | ||
Chars is a partial list or a list with an element E which is a variable | instantiation_error | ||
Codes is a partial list or a list with an element E which is a variable | instantiation_error | ||
Atom is neither a variable nor a an atom | type_error(atom, Atom) | ||
Chars is neither a partial list nor a list | type_error(list, Chars) | ||
Codes is neither a partial list nor a list | type_error(list, Codes) | ||
an element E of the Chars list is neither a variable nor a character | type_error(character, E) | ||
an element E of the Codes list is neither a variable nor an integer | type_error(integer, E) | ||
an element E of the Codes list is an integer but not a character code | representation_error(character_code) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(close, stream, SorA) | ||
SorA is a stream-term or alias but does not refer to a constant term stream. | domain_error(term_stream_or_alias, SorA) | ||
Stream is not a variable | type_error(variable, Stream) | ||
SorA is a variable | instantiation_error | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Chars is neither a partial list nor a list | type_error(list, Chars) | ||
Codes is neither a partial list nor a list | type_error(list, Codes) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an input stream | permission_error(close, stream, SorA) | ||
SorA is a stream-term or alias but does not refer to a constant term stream | domain_error(term_stream_or_alias, SorA) | ||
SorA is a variable | instantiation_error | ||
Char is neither a variable nor an in-character | type_error(in_character, Char) | ||
Code is neither a variable nor an integer | type_error(integer, Code) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(input, binary_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
The entity input from the stream is not a character | representation_error(character) | ||
Code is an integer but not an in-character code | representation_error(in_character_code) | ||
SorA is a variable | instantiation_error | ||
Code is neither a variable nor an integer | type_error(integer, Code) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(input, binary_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Char is neither a variable nor an in-character | type_error(in_character, Char) | ||
Code is neither a variable nor an integer | type_error(integer, Code) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(input, binary_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
The entity input from the stream is not a character | representation_error(character) | ||
Code is an integer but not an in-character code | representation_error(in_character_code) | ||
SorA is a variable | instantiation_error | ||
Char is a variable | instantiation_error | ||
Code is a variable | instantiation_error | ||
Char is neither a variable nor a character | type_error(character, Char) | ||
Code is neither a variable nor an integer | type_error(integer, Code) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(input, binary_stream, SorA) | ||
Code is an integer but not a character code | representation_error(character_code) | ||
SorA is a variable | instantiation_error | ||
Char is a variable | instantiation_error | ||
Code is a variable | instantiation_error | ||
Char is neither a variable nor a character | type_error(character, Char) | ||
Code is neither a variable nor an integer | type_error(integer, Code) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an input stream | permission_error(output, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(output, binary_stream, SorA) | ||
Code is an integer but not a character code | representation_error(character_code) | ||
SorA is a variable | instantiation_error | ||
Byte is neither a variable nor an in-byte | type_error(in_byte, Byte) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a text stream | permission_error(input, text_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Byte is neither a variable nor an in-byte | type_error(in_byte, Byte) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a text stream | permission_error(input, text_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Byte is a variable | instantiation_error | ||
Byte is neither a variable nor a byte | type_error(byte, Byte) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a text stream | permission_error(input, text_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Byte is a variable | instantiation_error | ||
Byte is neither a variable nor a byte | type_error(byte, Byte) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(output, stream, SorA) | ||
SorA is associated with a text stream | permission_error(output, text_stream, SorA) | ||
SorA is a variable | instantiation_error | ||
Options is a partial list or a list with an element E which is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
Options is neither a partial list nor a list | type_error(list, Options) | ||
an element E of the Options list is neither a variable nor a valid read option | domain_error(read_option, E) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(input, binary_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
a syntax error occurs and the value of the syntax_error Prolog flag is error (section 7.22.1) | syntax_error(atom explaining the error) | ||
SorA is a variable | instantiation_error | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Integer is neither a variable nor an integer | type_error(integer, Integer) | ||
Number is neither a variable nor a number | type_error(number, Number) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(input, binary_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
a syntax error occurs and the value of the syntax_error Prolog flag is error (section 7.22.1) | syntax_error(atom explaining the error) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an output stream | permission_error(input, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(input, binary_stream, SorA) | ||
SorA has stream properties end_of_stream(past) and eof_action(error) | permission_error(input, past_end_of_stream, SorA) | ||
a syntax error occurs and the value of the syntax_error Prolog flag is error (section 7.22.1) | syntax_error(atom explaining the error) | ||
FileName is neither a variable nor an atom | type_error(atom, FileName) | ||
Line is neither a variable nor an integer | type_error(integer, Line) | ||
Column is neither a variable nor an integer | type_error(integer, Column) | ||
Error is neither a variable nor an atom | type_error(atom, Error) | ||
Line is neither a variable nor an integer | type_error(integer, Line) | ||
Column is neither a variable nor an integer | type_error(integer, Column) | ||
'$VAR'(0) | is written as A | |
'$VAR'(1) | is written as B | |
... | ||
'$VAR'(25) | is written as Z | |
'$VAR'(26) | is written as A1 | |
'$VAR'(27) | is written as B1 |
SorA is a variable | instantiation_error | ||
Options is a partial list or a list with an element E which is a variable | instantiation_error | ||
Options is neither a partial list nor a list | type_error(list, Options) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
an element E of the Options list is neither a variable nor a valid write-option | domain_error(write_option, E) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an input stream | permission_error(output, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(output, binary_stream, SorA) | ||
Format sequence |
type of the argument |
Description |
~Na |
atom |
print the atom without quoting. N is minimal number of characters to print using spaces on the rigth if needed (default: the length of the atom) |
~Nc |
character code |
print the character associated with the code. N is the number of times to print the character (default: 1) |
~Nf
~Ne ~NE ~Ng ~NG |
float expression |
pass the argument Arg and
N to the C printf()
function as:
if N is not specified printf("%f",Arg) else printf("%.Nf",Arg). Similarly for ~Ne, ~NE, ~Ng and ~NG |
~Nd |
integer expression |
print the argument. N is the number of digits after the decimal point. If N is 0 no decimal point is printed (default: 0) |
~ND |
integer expression |
identical to ~Nd except that ',' separates groups of three digits to the left of the decimal point |
~Nr |
integer expression |
print the argument according to the radix N. 2 ≤ N ≤ 36 (default: 8). The letters a-z denote digits > 9 |
~NR |
integer expression |
identical to ~Nr except that the letters A-Z denote digits > 9 |
~Ns |
character code list |
print exactly N characters (default: the length of the list) |
~NS |
character list |
print exactly N characters (default: the length of the list) |
~i |
term |
ignore the current argument |
~k |
term |
pass the argument to write_canonical/1 (section 7.14.6) |
~p |
term |
pass the argument to print/1 (section 7.14.6) |
~q |
term |
pass the argument to writeq/1 (section 7.14.6) |
~w |
term |
pass the argument to write/1 (section 7.14.6) |
~~ |
none |
print the character '~' |
~Nn |
none |
print N new-line characters (default: 1) |
~N |
none |
print a new-line character if not at the beginning of a line |
~? |
atom |
use the argument as a nested format string |
%F |
atom, integer or float expression |
interface to the C function printf(3) for outputting atoms (C string), integers and floating point numbers. * are also allowed. |
SorA is a variable | instantiation_error | ||
Format is a partial list or a list with an element E which is a variable | instantiation_error | ||
Arguments is a partial list | instantiation_error | ||
Format is neither a partial list nor a list or an atom | type_error(list, Format) | ||
Arguments is neither a partial list nor a list | type_error(list, Arguments) | ||
an element E of the Format list is neither a variable nor a character code | representation_error(character_code, E) | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
an element E of Format is not a valid format control sequence | domain_error(format_control_sequence, E) | ||
the Arguments list does not contain sufficient elements | domain_error(non_empty_list, []) | ||
an element E of the Arguments list is a variable while a non-variable term was expected | instantiation_error | ||
an element E of the Arguments list is neither variable nor an atom while an atom was expected | type_error(atom, E) | ||
an element E of the Arguments cannot be evaluated as an arithmetic expression while an integer or a floating point number was expected | an arithmetic error (section 7.6.1) | ||
an element E of the Arguments list is neither variable nor character code while a character code was expected | representation_error(character_code, E) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an input stream | permission_error(output, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(output, binary_stream, SorA) | ||
Clause is a variable | instantiation_error | ||
Clause is neither a variable nor a callable term | type_error(callable, Clause) | ||
SorA is a variable | instantiation_error | ||
SorA is neither a variable nor a stream-term or alias | domain_error(stream_or_alias, SorA) | ||
SorA is not associated with an open stream | existence_error(stream, SorA) | ||
SorA is an input stream | permission_error(output, stream, SorA) | ||
SorA is associated with a binary stream | permission_error(output, binary_stream, SorA) | ||
Stream is neither a variable nor a stream-term | domain_error(stream, Stream) | ||
Specifier | Type | Associativity |
fx | prefix | no |
fy | prefix | yes |
xf | postfix | no |
yf | postfix | yes |
xfx | infix | no |
yfx | infix | left |
xfy | infix | right |
Priority | Specifier | Operators |
1200 | xfx | :- –> |
1200 | fx | :- |
1100 | xfy | ; |
1050 | xfy | -> |
1000 | xfy | , |
900 | fy | \+ |
700 | xfx | = \= =.. == \== @<
@=< @> @>= is =:= =\= < =< > >= |
600 | xfy | : |
500 | yfx | + - /\ \/ |
400 | yfx | * / // rem mod <<
>> |
200 | xfy | ** ^ |
200 | fy | + - \ |
Priority | Specifier | Operators |
750 | xfy | #<=> #\<=> |
740 | xfy | #==> #\==> |
730 | xfy | ## #\/ #\\/ |
720 | yfx | #/\ #\/\ |
710 | fy | #\ |
700 | xfx | #= #\= #< #=<
#> #>= #=# #\=# #<# #=<# #>#
#>=# |
500 | yfx | + - |
400 | yfx | * / // rem |
200 | xfy | ** |
200 | fy | + - |
Priority is a variable | instantiation_error | ||
OpSpecifier is a variable | instantiation_error | ||
Operator is a partial list or a list with an element E which is a variable | instantiation_error | ||
Priority is neither a variable nor an integer | type_error(integer, Priority) | ||
OpSpecifier is neither a variable nor an atom | type_error(atom, OpSpecifier) | ||
Operator is neither a partial list nor a list nor an atom | type_error(list, Operator) | ||
an element E of the Operator list is neither a variable nor an atom | type_error(atom, E) | ||
Priority is an integer not ≥ 0 and ≤ 1200 | domain_error(operator_priority, Priority) | ||
OpSpecifier is not a valid operator specifier | domain_error(operator_specifier, OpSpecifier) | ||
Operator is ',' or an element of the Operator list is ',' | permission_error(modify, operator, ',') | ||
OpSpecifier is a specifier such that Operator would have a postfix and an infix definition. | permission_error(create, operator, Operator) | ||
Priority is neither a variable nor an operator priority | domain_error(operator_priority, Priority) | ||
OpSpecifier is neither a variable nor an operator specifier | domain_error(operator_specifier, OpSpecifier) | ||
Operator is neither a variable nor an atom | type_error(atom, Operator) | ||
InChar is a variable | instantiation_error | ||
OutChar is a variable | instantiation_error | ||
InChar is neither a variable nor a character | type_error(character, InChar) | ||
OutChar is neither a variable nor a character | type_error(character, OutChar) | ||
InChar is neither a variable nor a character | type_error(character, InChar) | ||
OutChar is neither a variable nor a character | type_error(character, OutChar) | ||
Atom is a variable | instantiation_error | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
see associated predicate errors | (section 7.14.1) and (section 7.14.3) | ||
Chars is a partial list or a list with an element E which is a variable | instantiation_error | ||
Chars is neither a partial list nor a list | type_error(list, Chars) | ||
an element E of the Chars list is neither a variable nor a character | type_error(character, E) | ||
see associated predicate errors | (section 7.14.1) and (section 7.14.3) | ||
Codes is a partial list or a list with an element E which is a variable | instantiation_error | ||
Codes is neither a partial list nor a list | type_error(list, Codes) | ||
an element E of the Codes list is neither a variable nor an integer | type_error(integer, E) | ||
an element E of the Codes list is an integer but not a character code | representation_error(character_code, E) | ||
see associated predicate errors | (section 7.14.1) and (section 7.14.3) | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
see associated predicate errors | (section 7.14.6) and (section 7.14.7) | ||
Chars is neither a partial list nor a list | type_error(list, Chars) | ||
see associated predicate errors | (section 7.14.6) and (section 7.14.7) | ||
Codes is neither a partial list nor a list | type_error(list, Codes) | ||
see associated predicate errors | (section 7.14.6) and (section 7.14.7) | ||
p(X, Y) --> q(X), r(X, Y), s(Y).
p(X, Y, Start, End) :- q(X, Start, A), r(X, Y, A, B), s(Y, B, End).
assign(X,Y,Start,End) :- left(X, Start, A), A=[:=|B], right(Y, B, C), C=[;|End].
assign(X,Y,Start,End) :- left(X, Start, A), A=[:=|B], right(Y0, B, C), Y is Y0, C=[;|End].
List is neither a list nor a partial list | type_error(list, List) | ||
Remainder is neither a list nor a partial list | type_error(list, Remainder) | ||
Status is a variable | instantiation_error | ||
Status is neither a variable nor an integer | type_error(integer, Status) | ||
Goal is a variable | instantiation_error | ||
Goal is neither a variable nor a callable term | type_error(callable, Goal) | ||
The predicate indicator Pred of Goal does not correspond to an existing procedure and the value of the unknown Prolog flag is error (section 7.22.1) | existence_error(procedure, Pred) | ||
Functor is a variable | instantiation_error | ||
Functor is neither a variable nor an atom | type_error(atom, Functor) | ||
Deterministic is neither a variable nor a boolean | type_error(boolean, Deterministic) | ||
for call/2-11 the resulting arity of Goal (arity of Closure + N) is an integer > max_arity flag (section 7.22.1) | representation_error(max_arity) | ||
Counter is neither a variable nor an integer | type_error(integer, Counter) | ||
Lower is a variable | instantiation_error | ||
Lower is neither a variable nor an integer | type_error(integer, Lower) | ||
Upper is a variable | instantiation_error | ||
Upper is neither a variable nor an integer | type_error(integer, Upper) | ||
Atom is a variable | instantiation_error | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Length is neither a variable nor an integer | type_error(integer, Length) | ||
Length is an integer < 0 | domain_error(not_less_than_zero, Length) | ||
Atom1 and Atom12 are variables | instantiation_error | ||
Atom2 and Atom12 are variables | instantiation_error | ||
Atom1 is neither a variable nor an atom | type_error(atom, Atom1) | ||
Atom2 is neither a variable nor an atom | type_error(atom, Atom2) | ||
Atom12 is neither a variable nor an atom | type_error(atom, Atom12) | ||
Atom is a variable | instantiation_error | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
SubAtom is neither a variable nor an atom | type_error(atom, SubAtom) | ||
Before is neither a variable nor an integer | type_error(integer, Before) | ||
Length is neither a variable nor an integer | type_error(integer, Length) | ||
After is neither a variable nor an integer | type_error(integer, After) | ||
Before is an integer < 0 | domain_error(not_less_than_zero, Before) | ||
Length is an integer < 0 | domain_error(not_less_than_zero, Length) | ||
After is an integer < 0 | domain_error(not_less_than_zero, After) | ||
Char and Code are variables | instantiation_error | ||
Char is neither a variable nor a one-char atom | type_error(character, Char) | ||
Code is neither a variable nor an integer | type_error(integer, Code) | ||
Code is an integer but not a character code | representation_error(character_code) | ||
Char1 and Char2 are variables | instantiation_error | ||
Char1 is neither a variable nor a one-char atom | type_error(character, Char1) | ||
Char2 is neither a variable nor a one-char atom | type_error(character, Char2) | ||
Atom is a variable and Chars (or Codes) is a partial list or a list with an element which is a variable | instantiation_error | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Chars is neither a list nor a partial list | type_error(list, Chars) | ||
Codes is neither a list nor a partial list | type_error(list, Codes) | ||
Atom is a variable and an element E of the list Chars is neither a variable nor a one-char atom | type_error(character, E) | ||
Atom is a variable and an element E of the list Codes is neither a variable nor an integer | type_error(integer, E) | ||
Atom is a variable and an element E of the list Codes is an integer but not a character code | representation_error(character_code) | ||
Number and Atom are variables | instantiation_error | ||
Number is a variable and Chars (or Codes) is a partial list or a list with an element which is a variable | instantiation_error | ||
Number is neither a variable nor an number | type_error(number, Number) | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Number is a variable and Chars is neither a list nor a partial list | type_error(list, Chars) | ||
Number is a variable and Codes is neither a list nor a partial list | type_error(list, Codes) | ||
Number is a variable and an element E of the list Chars is neither a variable nor a one-char atom | type_error(character, E) | ||
Number is a variable and an element E of the list Codes is neither a variable nor an integer | type_error(integer, E) | ||
Number is a variable and an element E of the list Codes is an integer but not a character code | representation_error(character_code) | ||
Number is a variable, Atom (or Chars or Codes) cannot be parsed as a number and the value of the syntax_error Prolog flag is error (section 7.22.1) | syntax_error(atom explaining the error) | ||
Constant is a variable and Codes is a partial list or a list with an element which is a variable | instantiation_error | ||
Constant is neither a variable nor an atomic term | type_error(atomic, Constant) | ||
Constant is a variable and Codes is neither a list nor a partial list | type_error(list, Codes) | ||
Constant is a variable and an element E of the list Codes is neither a variable nor an integer | type_error(integer, E) | ||
Constant is a variable and an element E of the list Codes is an integer but not a character code | representation_error(character_code) | ||
Atom and Hash are both variables | instantiation_error | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Hash is neither a variable nor an integer | type_error(integer, Hash) | ||
Hash is an integer < 0 | domain_error(not_less_than_zero, Hash) | ||
Prefix is a variable | instantiation_error | ||
Hash is a variable | instantiation_error | ||
Prefix is neither a variable nor an atom | type_error(atom, Prefix) | ||
Hash is neither a variable nor an integer | type_error(integer, Hash) | ||
Hash is an integer < 0 | domain_error(not_less_than_zero, Hash) | ||
Atom is not a variable | type_error(variable, Atom) | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Atom is neither a variable nor an atom | type_error(atom, Atom) | ||
Property is neither a variable nor a n atom property term | domain_error(atom_property, Property) | ||
Property = length(E) or hash(E) and E is neither a variable nor an integer | type_error(integer, E) | ||
List1 is a partial list | instantiation_error | ||
List1 is neither a partial list nor a list | type_error(list, List1) | ||
List2 is neither a partial list nor a list | type_error(list, List2) | ||
GVarName | ::= | atom | whole content of a variable |
atom(Integer,...,Integer) | element of an array | ||
GVarName-Integer | sub-term selection | ||
Integer | ::= | integer | immediate value |
GVarName | indirect value |
a | the content of variable associated with a (any kind) |
t(1) | the 2nd element of the array associated with t |
t(k) | if the value associated with k is I, the Ith element of the array associated with t |
a-1-2 | if the value associated with a is f(g(a,b,c),2), the sub-term b |
GVarName is a variable | instantiation_error | ||
GVarName is neither a variable nor a callable term | type_error(callable, GVarName) | ||
GVarName contains an invalid argument number (or GVarName is an array) | domain_error(g_argument_selector, GVarName) | ||
GVarName contains an invalid index (or GVarName is not an array) | domain_error(g_array_index, GVarName) | ||
GVarName is used as an indirect index or argument selector and is not an integer | type_error(integer, GVarName) | ||
GVarName contains an argument selector and the assignment is backtrackable | domain_error(g_argument_selector, GVarName) | ||
Size is neither a variable nor an integer | type_error(integer, Size) | ||
Old is neither a variable nor an integer | type_error(integer, Old) | ||
New is neither a variable nor an integer | type_error(integer, New) | ||
GVarName stores an array | type_error(integer, g_array) | ||
GVarName stores a term T which is not an integer | type_error(integer, T) | ||
Bit is a variable | instantiation_error | ||
Bit is neither a variable nor an integer | type_error(integer, Bit) | ||
Bit is an integer < 0 | domain_error(not_less_than_zero, Bit) | ||
GVarName stores an array | type_error(integer, g_array) | ||
GVarName stores a term T which is not an integer | type_error(integer, T) | ||
my_g_inc(Var, Old, New) :- g_read(Var, Old), N is Value + 1, g_assign(Var, X), New = N.
test(Old) :- | testb(Old) :- | |
g_assign(x,1), | g_assign(x,1), | |
( g_read(x, Old), | ( g_read(x, Old), | |
g_assign(x, 2) | g_assignb(x, 2) | |
; g_read(x, Old), | ; g_read(x, Old), | |
g_assign(x, 3) | g_assign(x, 3) | |
). | ). |
test(B) :- | test(B) :- | |
g_assign(b, f(X)), | g_link(b, f(X)), | |
X = 12, | X = 12, | |
g_read(b, B). | g_read(b, B). |
| ?- g_assign(w, g_array(3)), g_read(w, X). X = g_array([0,0,0]) | ?- g_assign(w(0), 16), g_assign(w(1), 32), g_assign(w(2), 64), g_read(w, X). X = g_array([16,32,64])
| ?- g_assign(k, g_array([16,32,64])), g_read(k, X). X = g_array([16,32,64]) | ?- g_assign(k, g_array(3,null)), g_read(k, X), g_array_size(k, S). S = 3 X = g_array([null,null,null])
| ?- g_assign(w, g_array(2, g_array(3))), g_read(w, X). X = g_array([g_array([0,0,0]),g_array([0,0,0])]) | ?- ( for(I,0,1), for(J,0,2), K is I*3+J, g_assign(w(I,J), K), fail ; g_read(w, X) ). X = g_array([g_array([0,1,2]),g_array([3,4,5])]) | ?- g_read(w(1),X). X = g_array([3,4,5])
| ?- g_assign(w,g_array([1,2,g_array([a,b,c]), g_array(2,z),5])), g_read(w, X). X = g_array([1,2,g_array([a,b,c]), g_array([z,z]),5]) | ?- g_read(w(1), X), g_read(w(2,1), Y), g_read(w(3,1), Z). X = 2 Y = b Z = z | ?- g_read(w(1,2),X). uncaught exception: error(domain_error(g_array_index,w(1,2)),g_read/2)
| ?- g_assign(a, g_array([10,20,30])), g_read(a, X). X = g_array([10,20,30]) | ?- g_assign(a, g_array_extend(5,null)), g_read(a, X). X = g_array([10,20,30,null,null]) | ?- g_assign(a, g_array([10,20,30])), g_read(a, X). X = g_array([10,20,30]) | ?- g_assign(a, g_array_extend([1,2,3,4,5,6])), g_read(a, X). X = g_array([10,20,30,4,5,6])
| ?- g_assign(t, g_array_auto(3)), g_assign(t(1), foo), g_read(t,X). X = g_array([0,foo,0]) | ?- g_assign(t(5), bar), g_read(t,X). X = g_array([0,foo,0,0,0,bar,0,0]) | ?- g_assign(t, g_array_auto(2, g_array(2))), g_assign(t(1,1), foo), g_read(t,X). X = g_array([g_array([0,0]),g_array([0,foo])]) | ?- g_assign(t(3,0), bar), g_read(t,X). X = g_array([g_array([0,0]),g_array([0,foo]),g_array([0,0]),g_array([bar,0])]) | ?- g_assign(t(3,4), bar), g_read(t,X). uncaught exception: error(domain_error(g_array_index,t(3,4)),g_assign/2) | ?- g_assign(t, g_array_auto(2, g_array_auto(2))), g_assign(t(1,1), foo), g_read(t,X). X = g_array([g_array([0,0]),g_array([0,foo])]) | ?- g_assign(t(3,3), bar), g_read(t,X). X = g_array([g_array([0,0]),g_array([0,foo]),g_array([0,0]), g_array([0,0,0,bar])]) | ?- g_assign(t, g_array_auto(2, g_array_auto(2, null))), g_read(t(2,3), U), g_read(t, X). U = null X = g_array([g_array([null,null]),g_array([null,null]), g_array([null,null,null,null]),g_array([null,null])])
Flag |
Values |
Description |
ISO |
bounded |
true / false |
are integers
bounded ? |
Y |
max_integer |
an integer |
greatest integer |
Y |
min_integer |
an integer |
smallest integer |
Y |
integer_rounding_function |
toward_zero
down |
rnd(X) = integer part of X
rnd(X) = ⌊X⌋ (section 7.6.1) |
Y |
max_arity |
an integer |
maximum arity for compound terms (255) |
Y |
max_atom |
an integer |
maximum number of atoms |
N |
max_unget |
an integer |
maximum number of successive ungets |
N |
prolog_name |
an atom |
name of the Prolog system |
N |
prolog_version |
an atom |
version number of the Prolog system |
N |
prolog_date |
an atom |
date of the Prolog system |
N |
prolog_copyright |
an atom |
copyright message of the Prolog
system |
N |
Flag |
Values |
Description |
ISO |
char_conversion |
on / off |
is
character conversion activated ? |
Y |
debug |
on / off |
is the debugger
activated ? |
Y |
singleton_warning |
on / off |
warn
about named singleton variables ? |
N |
strict_iso |
on / off |
strict ISO
behavior ? |
N |
double_quotes |
atom chars codes atom_no_escape chars_no_escape codes_no_escape |
a double quoted constant is returned as:
an atom a list of characters a list of character codes as atom but ignore escape sequences as chars but ignore escape sequences as code but ignore escape sequences |
Y N |
back_quotes |
atom chars codes atom_no_escape chars_no_escape codes_no_escape |
a back quoted constant is returned as:
an atom a list of characters a list of character codes as atom but ignore escape sequences as chars but ignore escape sequences as code but ignore escape sequences |
N |
unknown |
error warning fail |
a predicate calls an unknown procedure:
an existence_error is raised a message is displayed then fails quietly fails |
Y |
syntax_error |
error warning fail |
a predicate causes a syntax error:
a syntax_error is raised a message is displayed then fails quietly fails |
N |
os_error |
error warning fail |
a predicate causes an O.S. error:
a system_error is raised a message is displayed then fails quietly fails |
N |
Flag is a variable | instantiation_error | ||
Value is a variable | instantiation_error | ||
Flag is neither a variable nor an atom | type_error(atom, Flag) | ||
Flag is an atom but not a valid flag | domain_error(prolog_flag, Flag) | ||
Value is inappropriate for Flag | domain_error(flag_value, Flag+Value) | ||
Value is appropriate for Flag but flag Flag is not modifiable | permission_error(modify, flag, Flag) | ||
Flag is neither a variable nor an atom | type_error(atom, Flag) | ||
Flag is an atom but not a valid flag | domain_error(prolog_flag, Flag) | ||
Functor is a variable | instantiation_error | ||
Arity is a variable | instantiation_error | ||
Functor is neither a variable nor an atom | type_error(atom, Functor) | ||
Arity is neither a variable nor an integer | type_error(integer, Arity) | ||
Functor is neither a variable nor an atom | type_error(atom, Functor) | ||
Arity is neither a variable nor an integer | type_error(integer, Arity) | ||
FileName is a variable | instantiation_error | ||
FileName is neither a variable nor an atom | type_error(atom, FileName) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Files is a partial list or a list with an element E which is a variable | instantiation_error | ||
Files is neither a partial list nor a list nor an atom | type_error(list, Files) | ||
an element E of the Files list is neither a variable nor an atom | type_error(atom, E) | ||
an element E of the Files list is an atom but not a valid pathname | domain_error(os_path, E) | ||
an element E of the Files list is a valid pathname but does not correspond to an existing source | existence_error(source_sink, E) | ||
an error occurs executing a directive | see call/1 errors (section 6.2.3) | ||
Files is a partial list or a list with an element E which is a variable | instantiation_error | ||
Files is neither a partial list nor a list nor an atom | type_error(list, Files) | ||
an element E of the Files list is neither a variable nor an atom | type_error(atom, E) | ||
an element E of the Files list is an atom but not a valid pathname | domain_error(os_path, E) | ||
an element E of the Files list is a valid pathname but does not correspond to an existing source | existence_error(source_sink, E) | ||
an error occurs executing a directive | see call/1 errors (section 6.2.3) | ||
Pred is a variable | instantiation_error | ||
Pred is neither a variable nor predicate indicator or an atom | type_error(predicate_indicator, Pred) | ||
Key | Description | Value |
user_time | user CPU time | [SinceStart, SinceLast] |
system_time | system CPU time | [SinceStart, SinceLast] |
cpu_time | total CPU time (user + system) | [SinceStart, SinceLast] |
real_time | absolute time | [SinceStart, SinceLast] |
local_stack | local stack sizes (control, environments, choices) | [UsedSize, FreeSize] |
global_stack | global stack sizes (compound terms) | [UsedSize, FreeSize] |
trail_stack | trail stack sizes (variable bindings to undo) | [UsedSize, FreeSize] |
cstr_stack | constraint trail sizes (finite domain constraints) | [UsedSize, FreeSize] |
Key is neither a variable nor a valid key | domain_error(statistics_key, Key) | ||
Value is neither a variable nor a list of two elements | domain_error(statistics_value, Value) | ||
Value is a list of two elements and an element E is neither a variable nor an integer | type_error(integer, E) | ||
Time is neither a variable nor an integer | type_error(integer, Time) | ||
Seed is a variable | instantiation_error | ||
Seed is neither a variable nor an integer | type_error(integer, Seed) | ||
Seed is an integer < 0 | domain_error(not_less_than_zero, Seed) | ||
Seed is neither a variable nor an integer | type_error(integer, Seed) | ||
Seed is an integer < 0 | domain_error(not_less_than_zero, Seed) | ||
Number is not a variable | type_error(variable, Number) | ||
Base is a variable | instantiation_error | ||
Base is neither a variable nor a number | type_error(number, Base) | ||
Max is a variable | instantiation_error | ||
Max is neither a variable nor a number | type_error(number, Max) | ||
Number is not a variable | type_error(variable, Number) | ||
File1 is a variable | instantiation_error | ||
File1 is neither a variable nor an atom | type_error(atom, File1) | ||
File2 is neither a variable nor an atom | type_error(atom, File2) | ||
File1 is an atom but not a valid pathname | domain_error(os_path, File1) | ||
File is a variable | instantiation_error | ||
File is neither a variable nor an atom | type_error(atom, File) | ||
Directory is neither a variable nor an atom | type_error(atom, Directory) | ||
Prefix is neither a variable nor an atom | type_error(atom, Prefix) | ||
Suffix is neither a variable nor an atom | type_error(atom, Suffix) | ||
File1 is a variable | instantiation_error | ||
File1 is neither a variable nor an atom | type_error(atom, File1) | ||
File2 is neither a variable nor an atom | type_error(atom, File2) | ||
File1 is an atom but not a valid pathname | domain_error(os_path, File1) | ||
Counter is neither a variable nor an integer | type_error(integer, Counter) | ||
N is a variable | instantiation_error | ||
N is neither a variable nor an integer | type_error(integer, N) | ||
N is an integer < 0 | domain_error(not_less_than_zero, N) | ||
Arg is neither a variable nor an atom | type_error(atom, Arg) | ||
Args is neither a partial list nor a list | type_error(list, Args) | ||
Name is neither a variable nor an atom | type_error(atom, Name) | ||
Value is neither a variable nor an atom | type_error(atom, Value) | ||
PathName is a variable | instantiation_error | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
PathName is an atom but not a valid pathname | domain_error(os_path, PathName) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
PathName is a variable | instantiation_error | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
PathName is an atom but not a valid pathname | domain_error(os_path, PathName) | ||
Files is neither a partial list nor a list | type_error(list, Files) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
PathName1 is a variable | instantiation_error | ||
PathName1 is neither a variable nor an atom | type_error(atom, PathName1) | ||
PathName1 is an atom but not a valid pathname | domain_error(os_path, PathName1) | ||
PathName2 is a variable | instantiation_error | ||
PathName2 is neither a variable nor an atom | type_error(atom, PathName2) | ||
PathName2 is an atom but not a valid pathname | domain_error(os_path, PathName2) | ||
an operating system error occurs and value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
PathName is a variable | instantiation_error | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
PathName is an atom but not a valid pathname | domain_error(os_path, PathName) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
PathName is a variable | instantiation_error | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
PathName is an atom but not a valid pathname | domain_error(os_path, PathName) | ||
Permission is a partial list or a list with an element which is a variable | instantiation_error | ||
Permission is neither an atom nor partial list or a list | type_error(list, Permission) | ||
an element E of the Permission list is neither a variable nor an atom | type_error(atom, E) | ||
an element E of the Permission is an atom but not a valid permission | domain_error(os_file_permission, Permission) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
PathName is a variable | instantiation_error | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
PathName is an atom but not a valid pathname | domain_error(os_path, PathName) | ||
Property is neither a variable nor a file property term | domain_error(os_file_property, Property) | ||
Property = absolute_file_name(E), real_file_name(E), type(E) or permission(E) and E is neither a variable nor an atom | type_error(atom, E) | ||
Property = last_modification(DateTime) and DateTime is neither a variable nor a compound term | type_error(compound, DateTime) | ||
Property = last_modification(DateTime) and DateTime is a compound term but not a structure dt/6 | domain_error(date_time, DateTime) | ||
Property = size(E) or last_modification(DateTime) and DateTime is a structure dt/6 but an element E is neither a variable nor an integer | type_error(integer, E) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Template is a variable | instantiation_error | ||
Template is neither a variable nor an atom | type_error(atom, Template) | ||
Template is an atom but not a valid pathname | domain_error(os_path, Template) | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Directory is a variable | instantiation_error | ||
Directory is neither a variable nor an atom | type_error(atom, Directory) | ||
Directory is an atom but not a valid pathname | domain_error(os_path, Directory) | ||
Prefix is a variable | instantiation_error | ||
Prefix is neither a variable nor an atom | type_error(atom, Prefix) | ||
PathName is neither a variable nor an atom | type_error(atom, PathName) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
DateTime is neither a variable nor a compound term | type_error(compound, DateTime) | ||
DateTime is a compound term but not a structure dt/6 | domain_error(date_time, DateTime) | ||
DateTime is a structure dt/6 and an element E is neither a variable nor an integer | type_error(integer, E) | ||
Hostname is neither a variable nor an atom | type_error(atom, HostName) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
OSVersion is neither a variable nor an atom | type_error(atom, OSVersion) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Architecture is neither a variable nor an atom | type_error(atom, Architecture) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Command is a variable | instantiation_error | ||
Command is neither a variable nor an atom | type_error(atom, Command) | ||
Status is neither a variable nor an integer | type_error(integer, Status) | ||
Command is a variable | instantiation_error | ||
Command is neither a variable nor an atom | type_error(atom, Command) | ||
Status is neither a variable nor an integer | type_error(integer, Status) | ||
Command is a variable | instantiation_error | ||
Command is neither a variable nor an atom | type_error(atom, Command) | ||
Arguments is a partial list or a list with an element which is a variable | instantiation_error | ||
Arguments is neither a partial list nor a list | type_error(list, Arguments) | ||
an element E of the Arguments list is neither a variable nor an atom | type_error(atom, E) | ||
Status is neither a variable nor an integer | type_error(integer, Status) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Command is a variable | instantiation_error | ||
Command is neither a variable nor an atom | type_error(atom, Command) | ||
Mode is a variable | instantiation_error | ||
Mode is neither a variable nor an atom | type_error(atom, Mode) | ||
Mode is an atom but neither read nor write. | domain_error(io_mode, Mode) | ||
Stream is not a variable | type_error(variable, Stream) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Command is a variable | instantiation_error | ||
Command is neither a variable nor an atom | type_error(atom, Command) | ||
StreamIn is not a variable | type_error(variable, StreamIn) | ||
StreamOut is not a variable | type_error(variable, StreamOut) | ||
StreamErr is not a variable | type_error(variable, StreamErr) | ||
Pid is not a variable | type_error(variable, Pid) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Pid is not a variable | type_error(variable, Pid) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
StreamIn is not a variable | type_error(variable, StreamIn) | ||
StreamOut is not a variable | type_error(variable, StreamOut) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Pid is a variable | instantiation_error | ||
Pid is neither a variable nor an integer | type_error(integer, Pid) | ||
Status is neither a variable nor an integer | type_error(integer, Status) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Pid is neither a variable nor an integer | type_error(integer, Pid) | ||
Pid is a variable | instantiation_error | ||
Pid is neither a variable nor an integer | type_error(integer, Pid) | ||
Signal is a variable | instantiation_error | ||
Signal is neither a variable nor an integer or an atom | type_error(integer, Signal) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Seconds is a variable | instantiation_error | ||
Seconds is neither a variable nor a number | type_error(number, Seconds) | ||
Seconds is a number < 0 | domain_error(not_less_than_zero, Seconds) | ||
Reads (or Writes) is a partial list or a list with an element E which is a variable | instantiation_error | ||
Reads is neither a partial list nor a list | type_error(list, Reads) | ||
Writes is neither a partial list nor a list | type_error(list, Writes) | ||
ReadyReads is neither a partial list nor a list | type_error(list, ReadyReads) | ||
ReadyWrites is neither a partial list nor a list | type_error(list, ReadyWrites) | ||
an element E of the Reads (or Writes) list is neither a stream-term or alias nor an integer | domain_error(stream_or_alias, E) | ||
an element E of the Reads (or Writes) list is not a selectable item | domain_error(selectable_item, E) | ||
an element E of the Reads (or Writes) list is an integer < 0 | domain_error(not_less_than_zero, E) | ||
an element E of the Reads (or Writes) list is a stream-tern or alias not associated with an open stream | existence_error(stream, E) | ||
an element E of the Reads list is associated with an output stream | permission_error(input, stream, E) | ||
an element E of the Writes list is associated with an input stream | permission_error(output, stream, E) | ||
TimeOut is a variable | instantiation_error | ||
TimeOut is neither a variable nor a number | type_error(number, TimeOut) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Domain is a variable | instantiation_error | ||
Domain is neither a variable nor an atom | type_error(atom, Domain) | ||
Domain is an atom but not a valid socket domain | domain_error(socket_domain, Domain) | ||
Socket is not a variable | type_error(variable, Socket) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Socket is a variable | instantiation_error | ||
Socket is neither a variable nor an integer | type_error(integer, Socket) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Socket is a variable | instantiation_error | ||
Socket is neither a variable nor an integer | type_error(integer, Socket) | ||
Address is a variable | instantiation_error | ||
Address is neither a variable nor a valid address | domain_error(socket_address, Address) | ||
Address = 'AF_UNIX'(E) and E is a variable | instantiation_error | ||
Address = 'AF_UNIX'(E) or 'AF_INET'(E, _) and E is neither a variable nor an atom | type_error(atom, E) | ||
Address = 'AF_UNIX'(E) and E is an atom but not a valid pathname | domain_error(os_path, E) | ||
Address = 'AF_INET'(_, E) and E is neither a variable nor an integer | type_error(integer, E) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Socket is a variable | instantiation_error | ||
Socket is neither a variable nor an integer | type_error(integer, Socket) | ||
Address is a variable | instantiation_error | ||
Address is neither a variable nor a valid address | domain_error(socket_address, Address) | ||
Address = 'AF_UNIX'(E) or 'AF_INET'(E, _) or Address = 'AF_INET'(_, E) and E is a variable | instantiation_error | ||
Address = 'AF_UNIX'(E) or 'AF_INET'(E, _) and E is neither a variable nor an atom | type_error(atom, E) | ||
Address = 'AF_UNIX'(E) and E is an atom but not a valid pathname | domain_error(os_path, E) | ||
Address = 'AF_INET'(_, E) and E is neither a variable nor an integer | type_error(integer, E) | ||
StreamIn is not a variable | type_error(variable, StreamIn) | ||
StreamOut is not a variable | type_error(variable, StreamOut) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Socket is a variable | instantiation_error | ||
Socket is neither a variable nor an integer | type_error(integer, Socket) | ||
Length is a variable | instantiation_error | ||
Length is neither a variable nor an integer | type_error(integer, Length) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
Socket is a variable | instantiation_error | ||
Socket is neither a variable nor an integer | type_error(integer, Socket) | ||
Client is not a variable | type_error(variable, Client) | ||
StreamIn is not a variable | type_error(variable, StreamIn) | ||
StreamOut is not a variable | type_error(variable, StreamOut) | ||
an operating system error occurs and the value of the os_error Prolog flag is error (section 7.22.1) | system_error(atom explaining the error) | ||
HostName and HostAddress are variables | instantiation_error | ||
HostName is neither a variable nor an atom | type_error(atom, HostName) | ||
HostAddress is neither a variable nor an atom | type_error(atom, HostAddress) | ||
Address is neither a variable nor a valid address | domain_error(socket_address, Address) | ||
Prompt is neither a variable nor an atom | type_error(atom, Pred) | ||
Prompt is a variable | instantiation_error | ||
Prompt is neither a variable nor an atom | type_error(atom, Pred) | ||
Word is a variable | instantiation_error | ||
Word is neither a variable nor an atom | type_error(atom, Word) | ||
Prefix is a variable | instantiation_error | ||
Prefix is neither a variable nor an atom | type_error(atom, Prefix) | ||
Word is neither a variable nor an atom | type_error(atom, Word) | ||
Constraint on X | Domain of X | extra_cstr | Lost values |
X #=< 512 | 0..512 | off | none |
X #\= 10 | 0..9:11..127 | on | 128..512 |
X #=< 100 | 0..9:11..100 | off | none |
Constraint on X | Domain of X | extra_cstr | Lost values |
X #=< 512 | 0..512 | off | none |
X #\= 10 | 0..9:11..127 | on | 128..512 |
X #>= 256 | Warning: Vector too small... | on | 128..512 |
N is neither a variable nor an integer | type_error(integer, N) | ||
N is neither a variable nor an integer | type_error(integer, N) | ||
N is a variable | instantiation_error | ||
N is neither a variable nor an integer | type_error(integer, N) | ||
N is an integer < 0 | domain_error(not_less_than_zero, N) | ||
Vars is not a variable but is a partial list | instantiation_error | ||
Vars is neither a variable nor an FD variable nor an integer nor a list | type_error(list, Vars) | ||
an element E of the Vars list is neither a variable nor an FD variable nor an integer | type_error(fd_variable, E) | ||
Lower is a variable | instantiation_error | ||
Lower is neither a variable nor an integer | type_error(integer, Lower) | ||
Upper is a variable | instantiation_error | ||
Upper is neither a variable nor an integer | type_error(integer, Upper) | ||
Vars is not a variable but is a partial list | instantiation_error | ||
Vars is neither a variable nor an FD variable nor an integer nor a list | type_error(list, Vars) | ||
an element E of the Vars list is neither a variable nor an FD variable nor an integer | type_error(fd_variable, E) | ||
Values is a partial list or a list with an element E which is a variable | instantiation_error | ||
Values is neither a partial list nor a list | type_error(list, Values) | ||
an element E of the Values list is neither a variable nor an integer | type_error(integer, E) | ||
X is a variable | instantiation_error | ||
X is neither an FD variable nor an integer | type_error(fd_variable, X) | ||
N is neither a variable nor an integer | type_error(integer, N) | ||
an element E of the Vars list is neither a variable nor an FD variable nor an integer | type_error(fd_variable, E) | ||
Values is neither a partial list nor a list | type_error(list, Values) | ||
X is a variable | instantiation_error | ||
X is neither an FD variable nor an integer | type_error(fd_variable, X) | ||
FD Expression | Result |
Prolog variable | domain 0..fd_max_integer |
FD variable X | domain of X |
integer number N | domain N..N |
+ E | same as E |
- E | opposite of E |
E1 + E2 | sum of E1 and E2 |
E1 - E2 | subtraction of E2 from E1 |
E1 * E2 | multiplication of E1 by E2 |
E1 / E2 | integer division of E1 by E2 (only
succeeds if the remainder is 0) |
E1 ** E2 | E1 raised to the power of E2
(E1 or E2 must be an integer) |
min(E1,E2) | minimum of E1 and E2 |
max(E1,E2) | maximum of E1 and E2 |
dist(E1,E2) | distance, i.e. |E1 - E2| |
E1 // E2 | quotient of the integer division of E1 by
E2 |
E1 rem E2 | remainder of the integer division of E1 by
E2 |
quot_rem(E1,E2,R) | quotient of the integer division of
E1 by E2
(R is the remainder of the integer division of E1 by E2) |
a sub-expression is of the form _ ** E and E is a variable | instantiation_error | ||
a sub-expression E is neither a variable nor an integer nor an FD arithmetic functor | type_error(fd_evaluable, E) | ||
an expression is too complex | resource_error(too_big_fd_constraint) | ||
X is neither an FD variable nor an integer | type_error(fd_variable, X) | ||
FD Expression | Result |
Prolog variable | domain 0..1 |
FD variable X | domain of X, X is constrained to be in 0..1 |
0 (integer) | 0 (false) |
1 (integer) | 1 (true) |
#\ E | not E |
E1 #<=> E2 | E1 equivalent to E2 |
E1 #\<=> E2 | E1 not equivalent to E2 (i.e. E1 different from E2) |
E1 ## E2 | E1 exclusive OR E2 (i.e. E1 not equivalent to E2) |
E1 #==> E2 | E1 implies E2 |
E1 #\==> E2 | E1 does not imply E2 |
E1 #/\ E2 | E1 AND E2 |
E1 #\/\ E2 | E1 NAND E2 |
E1 #\/ E2 | E1 OR E2 |
E1 #\\/ E2 | E1 NOR E2 |
a sub-expression E is neither a variable nor an integer (0 or 1) nor an FD boolean functor nor reified constraint | type_error(fd_bool_evaluable, E) | ||
an expression is too complex | resource_error(too_big_fd_constraint) | ||
a sub-expression is an invalid reified constraint | an arithmetic constraint error (section 8.6.1) | ||
List is a partial list | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
Count is neither an FD variable nor an integer | type_error(fd_variable, Count) | ||
Lower is a variable | instantiation_error | ||
Lower is neither a variable nor an integer | type_error(integer, Lower) | ||
Upper is a variable | instantiation_error | ||
Upper is neither a variable nor an integer | type_error(integer, Upper) | ||
an element E of the List list is an invalid boolean expression | an FD boolean constraint (section 8.7.1) | ||
List is a partial list | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
an element E of the List list is neither a variable nor an integer nor an FD variable | type_error(fd_variable, E) | ||
I is neither a variable nor an FD variable nor an integer | type_error(fd_variable, I) | ||
X is neither a variable nor an FD variable nor an integer | type_error(fd_variable, X) | ||
List is a partial list or a list with an element E which is a variable | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
an element E of the List list is neither a variable nor an integer | type_error(integer, E) | ||
I is neither a variable nor an FD variable nor an integer | type_error(fd_variable, I) | ||
X is neither a variable nor an FD variable nor an integer | type_error(fd_variable, X) | ||
List is a partial list | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
an element E of the List list is neither a variable nor an integer nor an FD variable | type_error(fd_variable, E) | ||
N is a variable | instantiation_error | ||
N is neither a variable nor an integer | type_error(integer, N) | ||
V is a variable | instantiation_error | ||
V is neither a variable nor an integer | type_error(integer, V) | ||
List is a partial list | instantiation_error | ||
List is neither a partial list nor a list | type_error(list, List) | ||
an element E of the List list is neither a variable nor an FD variable nor an integer | type_error(fd_variable, E) | ||
and(X,Y,Z):- fd_relation([[0,0,0],[0,1,0],[1,0,0],[1,1,1]], [X,Y,Z]).
and(X,Y,Z):- fd_relationc([[0,0,1,1],[0,1,0,1],[0,0,0,1]], [X,Y,Z]).
Relation is a partial list or a list with a sub-term E which is a variable | instantiation_error | ||
Relation is neither a partial list nor a list | type_error(list, Relation) | ||
an element E of the Relation list is neither a variable nor an integer | type_error(integer, E) | ||
Vars is a partial list | instantiation_error | ||
Vars is neither a partial list nor a list | type_error(list, Vars) | ||
an element E of the Vars list is neither a variable nor an integer nor an FD variable | type_error(fd_variable, E) | ||
Vars is a partial list or a list with an element E which is a variable | instantiation_error | ||
Vars is neither a partial list nor a list | type_error(list, Vars) | ||
an element E of the Vars list is neither a variable nor an integer nor an FD variable | type_error(fd_variable, E) | ||
Options is a partial list or a list with an element E which is a variable | instantiation_error | ||
Options is neither a partial list nor a list | type_error(list, Options) | ||
an element E of the Options list is neither a variable nor a labeling option | domain_error(fd_labeling_option, E) | ||
Goal is a variable | instantiation_error | ||
Goal is neither a variable nor a callable term | type_error(callable, Goal) | ||
The predicate indicator Pred of Goal does not correspond to an existing procedure and the value of the unknown Prolog flag is error (section 7.22.1) | existence_error(procedure, Pred) | ||
X is neither a variable nor an FD variable nor an integer | type_error(fd_variable, X) | ||
Foreign type | Prolog type | C type | Description of the C type |
integer | integer | long | value of the integer |
positive | positive integer | long | value of the integer |
float | floating point number | double | value of the floating point number |
number | number | double | value of the number |
atom | atom | int | internal key of the atom |
boolean | boolean | int | value of the boolean (0=false, 1=true) |
char | character | int | value of (the code of) the character |
code | character code | int | value of the character-code |
byte | byte | int | value of the byte |
in_char | in-character | int | value of the character or -1 for end-of-file |
in_code | in-character code | int | value of the character-code or -1 for end-of-file |
in_byte | in-byte | int | value of the byte or -1 for the end-of-file |
string | atom | char * | C string containing the name of the atom |
chars | character list | char * | C string containing the characters of the list |
codes | character-code list | char * | C string containing the characters of the list |
term | Prolog term | PlTerm | generic Prolog term |
typedef struct { Bool is_var; Bool unify; union { long l; char *s; double d; }value; }FIOArg;
void Get_Choice_Counter(void) TYPE Get_Choice_Buffer (TYPE) void No_More_Choice (void)
#include <string.h> #include "gprolog.h" Bool first_occurrence(char *str, long c, long *pos) { char *p; p = strchr(str, c); if (p == NULL) /* C does not appear in A */ return FALSE; /* fail */ *pos = p - str; /* set the output argument */ return TRUE; /* succeed */ }
| ?- first_occurrence(prolog, p, X). X = 0 | ?- first_occurrence(prolog, k, X). no | ?- first_occurrence(prolog, A, X). {exception: error(instantiation_error,first_occurrence/3)} | ?- first_occurrence(prolog, 1 ,X). {exception: error(type_error(character,1),first_occurrence/3)}
#include <string.h> #include "gprolog.h" Bool occurrence(char *str, long c, long *pos) { char **info_pos; char *p; info_pos = Get_Choice_Buffer(char **); /* recover the buffer */ if (Get_Choice_Counter() == 0) /* first invocation ? */ *info_pos = str; p = strchr(*info_pos, c); if (p == NULL) /* C does not appear */ { No_More_Choice(); /* remove choice-point */ return FALSE; /* fail */ } *pos = p - str; /* set the output argument */ *info_pos = p + 1; /* update next starting pos */ return TRUE; /* succeed */ }
| ?- occurrence(prolog, o, X). | ||
X = 2 ? | (here the user presses ; to compute another solution) | |
X = 4 ? | (here the user presses ; to compute another solution) | |
no | (no more solution) | |
| ?- occurrence(prolog, k, X). | ||
no |
#include <string.h> #include "gprolog.h" Bool occurrence2(char *str, long c, long *pos) { char **info_pos; char *p; info_pos = Get_Choice_Buffer(char **); /* recover the buffer */ if (Get_Choice_Counter() == 0) /* first invocation ? */ { p = strchr(str, c); if (p == NULL) /* C does not appear at all */ { No_More_Choice(); /* remove choice-point */ return FALSE; /* fail */ } *info_pos = p; } /* info_pos = an occurrence */ *pos = *info_pos - str; /* set the output argument */ p = strchr(*info_pos + 1, c); if (p == NULL) /* no more occurrence */ No_More_Choice(); /* remove choice-point */ else *info_pos = p; /* else update next solution */ return TRUE; /* succeed */ }
| ?- occurrence2(prolog, l, X). | ||
X = 3 | (here the user is not prompted since there is no more alternative) | |
| ?- occurrence2(prolog, o, X). | ||
X = 2 ? | (here the user presses ; to compute another solution) | |
X = 4 | (here the user is not prompted since there is no more alternative) |
#include "gprolog.h" Bool char_ascii(FIOArg *c, FIOArg *ascii) { if (!c->is_var) /* Char is not a variable */ { ascii->unify = TRUE; /* enforce unif. of Code */ ascii->value.l = c->value.l; /* set Code */ return TRUE; /* succeed */ } if (ascii->is_var) /* Code is also a variable */ Pl_Err_Instantiation(); /* emit instantiation_error */ c->value.l = ascii->value.l; /* set Char */ return TRUE; /* succeed */ }
| ?- char_ascii(a, X). X = 97 | ?- char_ascii(X, 65). X = 'A' | ?- char_ascii(a, 12). no | ?- char_ascii(X, X). {exception: error(instantiation_error,char_ascii/2)} | ?- char_ascii(1, 12). {exception: error(type_error(character,1),char_ascii/2)}
char *Atom_Name (int atom) int Atom_Length (int atom) Bool Atom_Needs_Quote (int atom) Bool Atom_Needs_Scan (int atom) Bool Is_Valid_Atom (int atom) int Create_Atom (char *str) int Create_Allocate_Atom(char *str) int Find_Atom (char *str) int ATOM_CHAR (char c) int atom_nil int atom_false int atom_true int atom_end_of_file
long Rd_Integer_Check (PlTerm term) long Rd_Positive_Check (PlTerm term) double Rd_Float_Check (PlTerm term) double Rd_Number_Check (PlTerm term) int Rd_Atom_Check (PlTerm term) int Rd_Boolean_Check (PlTerm term) int Rd_Char_Check (PlTerm term) int Rd_In_Char_Check (PlTerm term) int Rd_Code_Check (PlTerm term) int Rd_In_Code_Check (PlTerm term) int Rd_Byte_Check (PlTerm term) int Rd_In_Byte_Check (PlTerm term) char *Rd_String_Check (PlTerm term) char *Rd_Chars_Check (PlTerm term) char *Rd_Codes_Check (PlTerm term) int Rd_Chars_Str_Check(PlTerm term, char *str) int Rd_Codes_Str_Check(PlTerm term, char *str)
int Rd_Proper_List_Check(PlTerm term, PlTerm *arg) PlTerm *Rd_List_Check (PlTerm term) PlTerm *Rd_Compound_Check (PlTerm term, int *functor, int *arity) PlTerm *Rd_Callable_Check (PlTerm term, int *functor, int *arity)
Bool Un_Integer_Check (long n, PlTerm term) Bool Un_Positive_Check(long n, PlTerm term) Bool Un_Float_Check (double n, PlTerm term) Bool Un_Number_Check (double n, PlTerm term) Bool Un_Atom_Check (int atom, PlTerm term) Bool Un_Boolean_Check (int b, PlTerm term) Bool Un_Char_Check (int c, PlTerm term) Bool Un_In_Char_Check (int c, PlTerm term) Bool Un_Code_Check (int c, PlTerm term) Bool Un_In_Code_Check (int c, PlTerm term) Bool Un_Byte_Check (int b, PlTerm term) Bool Un_In_Byte_Check (int b, PlTerm term) Bool Un_String_Check (char *str, PlTerm term) Bool Un_Chars_Check (char *str, PlTerm term) Bool Un_Codes_Check (char *str, PlTerm term)
Bool Un_Proper_List_Check(int size, PlTerm *arg, PlTerm term) Bool Un_List_Check (PlTerm *arg, PlTerm term) Bool Un_Compound_Check (int functor, int arity, PlTerm *arg, PlTerm term) Bool Un_Callable_Check (int functor, int arity, PlTerm *arg, PlTerm term)
void Check_For_Un_Integer (PlTerm term) void Check_For_Un_Positive(PlTerm term) void Check_For_Un_Float (PlTerm term) void Check_For_Un_Number (PlTerm term) void Check_For_Un_Atom (PlTerm term) void Check_For_Un_Boolean (PlTerm term) void Check_For_Un_Char (PlTerm term) void Check_For_Un_In_Char (PlTerm term) void Check_For_Un_Code (PlTerm term) void Check_For_Un_In_Code (PlTerm term) void Check_For_Un_Byte (PlTerm term) void Check_For_Un_In_Byte (PlTerm term) void Check_For_Un_String (PlTerm term) void Check_For_Un_Chars (PlTerm term) void Check_For_Un_Codes (PlTerm term)
void Check_For_Un_List (PlTerm term) void Check_For_Un_Compound(PlTerm term) void Check_For_Un_Callable(PlTerm term) void Check_For_Un_Variable(PlTerm term)
void Check_For_Un_List(PlTerm term) { if (!Blt_List_Or_Partial_List(term)) Pl_Err_Type(type_list, term); }
PlTerm Mk_Integer (long n) PlTerm Mk_Positive(long n) PlTerm Mk_Float (double n) PlTerm Mk_Number (double n) PlTerm Mk_Atom (int atom) PlTerm Mk_Boolean (int b) PlTerm Mk_Char (int c) PlTerm Mk_In_Char (int c) PlTerm Mk_Code (int c) PlTerm Mk_In_Code (int c) PlTerm Mk_Byte (int b) PlTerm Mk_In_Byte (int b) PlTerm Mk_String (char *str) PlTerm Mk_Chars (char *str) PlTerm Mk_Codes (char *str)
PlTerm Mk_Proper_List(int size, PlTerm *arg) PlTerm Mk_List (PlTerm *arg) PlTerm Mk_Compound (int functor, int arity, PlTerm *arg) PlTerm Mk_Callable (int functor, int arity, PlTerm *arg)
Bool Blt_Var (PlTerm term) Bool Blt_Non_Var (PlTerm term) Bool Blt_Atom (PlTerm term) Bool Blt_Integer (PlTerm term) Bool Blt_Float (PlTerm term) Bool Blt_Number (PlTerm term) Bool Blt_Atomic (PlTerm term) Bool Blt_Compound (PlTerm term) Bool Blt_Callable (PlTerm term) Bool Blt_List (PlTerm term) Bool Blt_Partial_List (PlTerm term) Bool Blt_List_Or_Partial_List(PlTerm term) Bool Blt_Fd_Var (PlTerm term) Bool Blt_Non_Fd_Var (PlTerm term) Bool Blt_Generic_Var (PlTerm term) Bool Blt_Non_Generic_Var (PlTerm term) int Type_Of_Term (PlTerm term) int List_Length (PlTerm list)
Bool Blt_Term_Eq (PlTerm term1, PlTerm term2) Bool Blt_Term_Neq(PlTerm term1, PlTerm term2) Bool Blt_Term_Lt (PlTerm term1, PlTerm term2) Bool Blt_Term_Lte(PlTerm term1, PlTerm term2) Bool Blt_Term_Gt (PlTerm term1, PlTerm term2) Bool Blt_Term_Gte(PlTerm term1, PlTerm term2)
int Term_Compare(PlTerm term1, PlTerm term2)
void Copy_Term (PlTerm *dst_adr, PlTerm *src_adr) void Copy_Contiguous_Term(PlTerm *dst_adr, PlTerm *src_adr) int Term_Size (PlTerm term)
Bool Blt_Eq (PlTerm expr1, PlTerm expr2) Bool Blt_Neq(PlTerm expr1, PlTerm expr2) Bool Blt_Lt (PlTerm expr1, PlTerm expr2) Bool Blt_Lte(PlTerm expr1, PlTerm expr2) Bool Blt_Gt (PlTerm expr1, PlTerm expr2) Bool Blt_Gte(PlTerm expr1, PlTerm expr2)
void Math_Load_Value(PlTerm expr, PlTerm *result)
void Set_C_Bip_Name (char *functor, int arity) void Unset_C_Bip_Name(void)
void Pl_Query_Begin (Bool recoverable) int Pl_Query_Call (int functor, int arity, PlTerm *arg) int Pl_Query_Next_Solution(void) void Pl_Query_End (int op) PlTerm Pl_Get_Exception (void) void Pl_Exec_Continuation (int functor, int arity, PlTerm *arg)
#include <string.h> #include "gprolog.h" Bool my_call(PlTerm goal) { PlTerm *arg; int functor, arity; int result; arg = Rd_Callable_Check(goal, &functor, &arity); Pl_Query_Begin(FALSE); result = Pl_Query_Call(functor, arity, arg); Pl_Query_End(PL_KEEP_FOR_PROLOG); return (result == PL_SUCCESS); }
| ?- my_call(write(hello)). | ||
hello | ||
| ?- my_call(for(X,1,3)). | ||
X = 1 ? | (here the user presses ; to compute another solution) | |
X = 2 ? | (here the user presses ; to compute another solution) | |
X = 3 | (here the user is not prompted since there is no more alternative) | |
| ?- my_call(1). | ||
{exception: error(type_error(callable,1),my_call/1)} | ||
| ?- my_call(call(1)). | ||
no |
#include <string.h> #include "gprolog.h" Bool my_call(PlTerm goal) { PlTerm *args; int functor, arity; int result; args = Rd_Callable_Check(goal, &functor, &arity); Pl_Query_Begin(FALSE); result = Pl_Query_Call(functor, arity, args); Pl_Query_End(PL_KEEP_FOR_PROLOG); if (result == PL_EXCEPTION) { PlTerm except = Pl_Get_Exception(); Pl_Exec_Continuation(Find_Atom("throw"), 1, &except); } return result; }
| ?- my_call(call(1)). | ||
{exception: error(type_error(callable,1),my_call/1)} |
#include <string.h> #include "gprolog.h" Bool my_call(PlTerm goal) { PlTerm *args; int functor, arity; args = Rd_Callable_Check(goal, &functor, &arity); Pl_Exec_Continuation(functor, arity, args); return TRUE; }
#include <string.h> #include "gprolog.h" Bool all_op(PlTerm list) { PlTerm op[1024]; PlTerm args[3]; int n = 0; int result; Pl_Query_Begin(TRUE); args[0] = Mk_Variable(); args[1] = Mk_Variable(); args[2] = Mk_Variable(); result = Pl_Query_Call(Find_Atom("current_op"), 3, args); while (result) { op[n++] = Mk_Atom(Rd_Atom(args[2])); /* arg #2 is the name of the op */ result = Pl_Query_Next_Solution(); } Pl_Query_End(PL_RECOVER); return Un_Proper_List_Check(n, op, list); }
| ?- all_op(L). L = [:-,:-,\=,=:=,#>=,#<#,@>=,-->,mod,#>=#,**,*,+,+,',',...] | ?- findall(X,current_op(_,_,X),L). L = [:-,:-,\=,=:=,#>=,#<#,@>=,-->,mod,#>=#,**,*,+,+,',',...]
int Start_Prolog (int argc, char *argv[]) void Stop_Prolog (void) void Reset_Prolog (void) Bool Try_Execute_Top_Level(void)
int Main_Wrapper(int argc, char *argv[]) { int nb_user_directive; Bool top_level; nb_user_directive = Start_Prolog(argc, argv); top_level = Try_Execute_Top_Level(); Stop_Prolog(); if (top_level || nb_user_directive) return 0; fprintf(stderr, "Warning: no initial goal executed\n" " use a directive :- initialization(Goal)\n" " or remove the link option --no-top-level" " (or --min-bips or --min-size)\n"); return 1; } int main(int argc, char *argv[]) { return Main_Wrapper(argc, argv); }
parent(bob, mary). parent(jane, mary). parent(mary, peter). parent(paul, peter). parent(peter, john). anc(X, Y):- parent(X, Y). anc(X, Z) :- parent(X, Y), anc(Y, Z).
static int Main_Wrapper(int argc, char *argv[]) { int func; WamWord arg[10]; char str[100]; char *sol[100]; int i, nb_sol = 0; Bool res; Start_Prolog(argc, argv); func = Find_Atom("anc"); for (;;) { printf("\nEnter a name (or 'end' to finish): "); scanf("%s", str); if (strcmp(str, "end") == 0) break; Pl_Query_Begin(TRUE); arg[0] = Mk_Variable(); arg[1] = Mk_String(str); nb_sol = 0; res = Pl_Query_Call(func, 2, arg); while (res) { sol[nb_sol++] = Rd_String(arg[0]); res = Pl_Query_Next_Solution(); } Pl_Query_End(PL_RECOVER); for (i = 0; i < nb_sol; i++) printf(" solution: %s\n", sol[i]); printf("%d solution(s)\n", nb_sol); } Stop_Prolog(); return 0; } int main(int argc, char *argv[]) { return Main_Wrapper(argc, argv); }
Enter a name (or 'end' to finish): john solution: peter solution: bob solution: jane solution: mary solution: paul 5 solution(s) Enter a name (or 'end' to finish): mary solution: bob solution: jane 2 solution(s) Enter a name (or 'end' to finish): end
|
|
This document was translated from LATEX by HEVEA.