Setting up a Programming Environment for COP 4020

Spring 2006.

Last updated 2006-01-27-16:06

Introduction

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.

Contact info

Name: Chris Millward

Email:cmillward at cs dot ucf dot edu

Office: CSB 114

Office hours: Mon. and Wed. 10am-11:30am

I am on campus every weekday except Thursday. If you cannot come during office hours, email me and we can set up a meeting.

Lisp

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:

Special Notes

Common Lisp vs. Scheme

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.

Undefined Variable Warnings

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 defineDto be a variable, enter(defvar d).Dis now a global variable that you can assign at will.

Local Common Lisp setup

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.

Using SBCL on Olympus

  1. Connect to Olympus
  2. At the prompt, the lisp environment can be accessed by enteringsbcl
  3. This will put you into the command line interpreter. You can now load outside files, or define/call functions within the interpreter.

Notes on SBCL in Olympus

If[BACKSPACE]is causing^Hto be inserted into the string, then hittingCTRL-Hshould act as backspace within the interpreter.

Loading outside files

To load a file namedtest.lthat you have written at command line type(load 'test.l)

Prolog

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.

Local Prolog setup

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).

  1. Download SWI-Prologfor your appropriate machine.
  2. Follow installation instructions.

Using GNU Prolog on Olympus

Using the Prolog environment provided on Olympus is another good option.

  1. Connect to Olympus using your SSH program.
  2. To start a fresh Prolog session typegprolog.This will bring you into the Prolog shell.

Defining functions in the interpreter

The prompt for calling predicates in Prolog looks like?-

To define a new predicate, saymother(X,Y)

  1. at prompt enter:[user].
  2. you are now able to define predicates, so enter:

    mother(martha,george).

    mother(linda,paul).

    mother(gracie,lacy).

  3. When you are done defining predicates, and want to be able to query them, simply pressCTL-Dto return you to the prompt.

Loading files into the interpreter

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:

  1. To load a filefile.plwith a.plending that is in the current directory

    ?- [file].

  2. To load a file without a.plending, i.e.file.prolog, even if it is in the current directory, you must quote the file name

    ?- ['file.prolog'].

  3. To load a file in another directory (foo/bar/file.pl), you must quote the file name and path

    ?- ['foor/bar/file.pl'].

  4. When in doubt (or if a file should be loading, but its not) try quoting it.

Connecting to Olympus

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.