Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
GNU Prolog


1. GNU Prolog
GNU PrologProlog is a logic programming language.

GNU Prolog is a free Prolog compiler with constraint solving over finite domains developed by Daniel Diaz. From the GNU Prolog web site at http://www.gprolog.org/ .

2. CentOS installation
The following Linux command(s) install GNU Prolog.
sudo yum -y install gprolog


3. Installed version
The following Linux command(s) verify the installed version.
gprolog --version

On 2019-08-05 the output was as follows.
Prolog top-Level (GNU Prolog) 1.4.4 By Daniel Diaz Copyright (C) 1999-2013 Daniel Diaz GNU Prolog comes with ABSOLUTELY NO WARRANTY. This is free software; see the source or the file named COPYING for copying conditions.


4. Hello world in Prolog
The file type of a Prolog program file is pro.

The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.pro

Create the following program text in the editor that will output the text "Hello world"
:- initialization(main). main:- print('Hello world'),nl.

To exit with save, remember to press Ctrl-X, then "y" (for yes) and Enter to exit.

The following Linux command(s) run the program.
gplc --no-top-level ~/hello.pro ~/hello

The output should be as follows.
Hello world

The following Linux command(s) combine the compile and run steps.
gplc --no-top-level ~/hello.pro && ~/hello

On the output was as follows.
Hello world


5. End of page