% 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) |