PrologThis Web page provides access to some example Prolog programs that run under yap (yet another prolog) on the Linux server. For more information on yap, see the Online Reference Manual. Example of UsageThose with accounts on the CIS Linux server can copy these examples from /www/carlsond/prolog. For example, to copy the list.pro example to your current directory you could use the following command:
Note the period. It represents your current directory and is NOT optional
(unlike in DOS). If you simply want to copy all of the Prolog examples to
your current directory you could do so as follows. Note that the * matches
all files in the given directory.
To run a Prolog program, you first start yap with the yap
command at the Linux command prompt. Then consult the desired Prolog
source file and give the desired goal. (Read the comments in each program to
see what an appropriate goal might be for that program.) Here is an example,
where it is assumed that the Prolog source code is in a file called
ancestor.pro and that the desired goal is
ancestor(X, Y) .
To exit from yap, press CTRL c and then enter e .
Another Example of UsageAs another example, let's use the tictac.pro example program. Copy it to your current directory as follows, being careful to include that final period (which stands for the current directory).
To run this Prolog program, you first start yap with the yap
command at the Linux command prompt. Then consult the Prolog source file as follows.
Next, give the appropriate goal, followed by a period. For the tictac.pro game, the goal
is go, so you would enter:
Follow the onscreen directions for playing tic-tac-toe.To exit from yap, press CTRL c and then enter e to exit.
Don't forget to exit from Linux as well, by entering the command exit .Example Prolog Programs and Other Examples
Instructor: Br. David Carlson |