Sunday, February 20, 2011

Installing Prolog on Puppy Linux, howto

From the book, Seven Languages in Seven Weeks, I notice a trend toward specialty languages being glued together by Ruby, or any scripting language. We can use the right tool for the right purpose instead of one "sledgehammer" only! Some examples are Prolog for rules (or logic) and Io (w/s "io language") for parsing.

Today I installed the package SWI Prolog, useful for developing in Prolog, the logic computer programming language, on a computer running Puppy Linux (Quirky Retro 1.2).

Here's how I did it:

o From Debian.org, download two 'lenny' packages:

swi-prolog_5swi-prolog_5.6.58-2_i386.deb
libgmp3c2_4.2.2+dfsg-3_i386.deb

o In the ROX-Filer file manager, click their icons to install them.

o Create a file, ~/.plrc containing the single line:

:- set_prolog_flag(editor,'geany').

o Within ~/my-documents, create and change to the directory, 'prolog'.

o Associate the file extension, '.pl' with SWI Prolog. Create a file like 'any.pl'. Right-click it in ROX-Filer and edit the run command to be:

urxvt -e swipl -s "$@"

Now you can click on a file with extension '.pl' and it will be loaded by the interpreter.

To make changes, type, 'edit.'. The interpreter will re-read the file when you close the editor. Type 'halt.' to end the session.

One example to get you started: if you type 'alice.' into a file, and in the interpreter type 'alice.', it will respond with, 'true'.

For further information, the SWI Prolog user manual is available off-line at:

file:///usr/lib/swi-prolog/doc/Manual/index.html

Their FAQ is:

http://www.swi-prolog.org/FAQ/

Some tutorials appropriate to beginners:

http://www.bitwisemag.com/copy/programming/prolog/intro/firststeps.html
http://www.learnprolognow.org/
http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/contents.html
http://www.doc.gold.ac.uk/~mas02gw/prolog_tutorial/prologpages/

Copyright (c) 2011 Mark D. Blackwell.

No comments:

Post a Comment

Thanks for commenting on my post!