LISP for CS 480/580

Our goal for this quarter is to learn enough LISP to see how it facilitates AI programming. There are many different LISP compilers and interpreters. We have GNU Common LISP running on prime. To start LISP, enter:

gcl

You can enter s-expressions at the > prompt, and you will see the results of evaluating them. To load a LISP program from a file, enter:

(load 'FILENAME)

This is useful if your program is of any length, as it can save a lot of retyping. Note that gcl expects your filename to be in all capital letters. There really isn't a good reason for this, but you will get an aggravating error message if you try to load a file which has been named with lower case letters.

If you do encounter an error message and see the error prompt >>, you can usually bounce back to the top level prompt by entering:

:q

Then you can try again. Because learning a full LISP environment is beyond the scope of this class, it is suggested that mistakes be corrected in the program file. Just reload the program file when you have finished making corrections.

One useful feature of the LISP environment, especially for following recursion, is the trace. To use it, enter:

(trace function-name)

where function-name is the name of a function you have defined using defun and loaded into gcl. Then run the function, as usual:

(function-name params)

to follow its operation. To run the function in normal mode, after the trace, either reload it, or enter:

(untrace function-name)

To exit LISP, enter:

(bye)

Online Reference

A LISP Text Book, by Guy L. Steele, Jr., is available online.