Summer 2006.
Last updated 2006-05-15
If you have trouble with gettingLisporPrologrunning,please contact me (via email)ASAP! Getting into programming in these languages should have as few barriers as possible. Setting up your programming environment should not be a struggle.
Name: Alex Cook
Email:acook at cs dot ucf dot edu
Office: CSB 114
Office hours: Tue. and Thur. 4:45pm – 5:45pm
I am on campus every weekday except Friday. If you cannot come during office hours, email me and we can set up a meeting.
I recommend that you use a Common Lisp environment for programming for this class. There are many choices, and it is a standard that is used in many areas. Also, I am most familiar with it, so I will be able to help you with this if you are having trouble. You have a few choices:
Most of the simple operators that you will use in Common Lisp have an immediate analgous function in Scheme. This can be seen in thethis table showing the corresponding functions in Scheme and CL.
If you are attempting to run simple examples in the Lisp interpreter, such as(setq d '(1 2 3))
you might recieve a warning such-as
; in: LAMBDA NIL ; (SETQ D '(1 2 3)) ; ; caught WARNING: ; undefined variable: D ; ; caught WARNING: ; This variable is undefined: ; D ; ; compilation unit finished ; caught 2 WARNING conditions
In order to not get these warnings, you should just declare the variables before you use them. So, to defineD
to be a variable, enter(defvar d)
.D
is now a global variable that you can assign at will.
For this class the de facto Lisp implementation isLispworks. They offer a free personal version for all operating systems. It is very easy to install, and gives you a powerful environment. The newestLispworks trial version can be downloaded here.
To download you will be required to provide your name/email address. Don't worry about it, they won't spam you.
The installation process should relatively easy, as I recall they have simple instructions to follow. You can refer to theRelease Notes and Installation Guide (in PDF). Contact me if you are having trouble getting it installed.
sbcl
If[BACKSPACE]
is causing^H
to be inserted into the string, then hittingCTRL-H
should act as backspace within the interpreter.
To load a file namedtest.l
that you have written at command line type(load 'test.l)
As with Lisp you have the option of either using the software provided on the olympus server, or installing a local version on your own machine.
There are many different Prolog implementations, but the one we will recommend for this course isSWI-Prolog.
It is cross-platform and includes a complete environment (including an integrated editor).
Using the Prolog environment provided on Olympus is another good option.
gprolog
.This will bring you into the Prolog shell.The prompt for calling predicates in Prolog looks like?-
To define a new predicate, saymother(X,Y)
[user].
you are now able to define predicates, so enter:
mother(martha,george).
mother(linda,paul).
mother(gracie,lacy).
When you are done defining predicates, and want to be able to query them, simply pressCTL-D
to return you to the prompt.
If you want to develop your Prolog programs in a text editor, and then load them into the interpreter, so that you have a copy of them (recommended) - then follow below.
The function to load a Prolog file isconsult
. If you have a program calledappend.pl
(in the same directory you started the Prolog interpreter from) you can load it with the following command.
?- consult('append.pl').
A syntactic sugar forconsult('path').
is['path'].
. This will save you some time if you will be loading a lot of files.
Some other examples of loading files:
To load a filefile.pl
with a.pl
ending that is in the current directory
?- [file].
To load a file without a.pl
ending, i.e.file.prolog
, even if it is in the current directory, you must quote the file name
?- ['file.prolog'].
To load a file in another directory (foo/bar/file.pl
), you must quote the file name and path
?- ['foor/bar/file.pl'].
When in doubt (or if a file should be loading, but its not) try quoting it.
To connect to Olympus you will need a ssh client.
The address isolympus.acs.ucf.edu
, and you must use the username and password provided to you by the department. If you have troubles with this please contact theComputer Help Deskby email or phone (407) 823-5117.