- Check the Prolog Help Pages.
- There Are Two Ways to Execute Prolog Commands:
- Interactive mode:
Activate the Prolog interpreter and interactively execute Prolog commands.
For example,
gandalf> gprolog
GNU Prolog 1.2.19
By Daniel Diaz
Copyright (C) 1999-2005 Daniel Diaz
| ?- write('Hello World!').
Hello World!
yes
| ?- [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 ? ;
X = s(s(0)) ? ;
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).
| ?- halt.
gandalf>
|
- Batch mode:
- Create a Prolog program such as HelloWorld.pro .
- Compile the program. For example,
gandalf> gplc -o Hello HelloWorld.pro
|
- Execute the program. For example,
gandalf> ./Hello
GNU Prolog 1.2.19
By Daniel Diaz
Copyright (C) 1999-2005 Daniel Diaz
| ?- hello.
Hello, World!
yes
| ?- halt.
gandalf>
|
|