Contents | Getting Started


This book is a primer on Lisp programming. It is written for any student wishing to gain a basic proficiency in Lisp, regardless of his or her background in computing. In general, the level of discussion is appropriate for any high school student, college student, or computer professional. A knowledge of elementary calculus will make some of the later examples easier to understand but is by no means required for the rest of the book.

The book was written originally by Jeff Shrager (currently at Carnegie-Mellon University) and Steve Bagley (currently at MIT) while they were undergraduates at the University of Pennsylvania. The Moore School Computing Facility, in the School of Engineering and Applied Science, at the University of Pennsylvania supplied computer time so that it could be developed online. Additional material was contributed by Stewart Schiffman of the Gnosis staff, and by Steve Cherry, author of P-LISP, which is the dialect of Lisp that the examples in this book use.


Lisp is important. Lisp is one of the oldest languages still in active use. It was invented for and is still used (workshipped) by computer scientists in "artificial intelligence". AI, as it is called, is an area of active computer science research. For this work, Lisp is indispensable.

Lisp is simple. Many computer languages force the user to deal with messy details of the computer on which they are run. In Lisp you don't worry about the mechanism of the computer. Also, the syntax, or format, of Lisp expressions is regular and consistent.

Lisp is fun. The types of problems usually dealt with in Lisp often include games and puzzles. Also, Lisp sessions are completely interactive. This interaction gives the user a greater sense of control over the machine, and makes the computer more of a "partner in thinking". Don't forget that for many years all computer systems were "batch," which meant that jobs had to be submitted on punched cards. The computer that P-Lisp runs on is substantially more powerful and vastly easier to use than most of those early machines.


Lisp was developed in the late 1950s by John McCarthy at MIT to serve as an algebraic list-processing language (LISP-LISt Processor) for work in the then-new field of artificial intelligence. The first work on implementation began in 1958 and Lisp 1 was born. A second version, called Lisp 1.5, was completed in the next few years. Lisp 1.5 is the precursor of most of the Lisp systems in existence today. During the 1960s several other versions were developed across the country for various different machines. MacLisp from MIT, InterLisp, formerly BBN Lisp, and MTSLisp from the University of Michigan are three currently available.

The dialect spoken in this book is P-Lisp. This is yet another Lisp system, but this one runs on the Apple and various other microcomputer systems. Personal Lisp computers are a net innovation in the computer world. MIT has big microcomputers that run a MacLisp derivative. Although P-Lisp isn't as powerful as those microcomputers (primarily because the computers it runs on are much smaller), the ideal of having your own Lisp processor remains. In particular, this version of the book goes with P-Lisp version 3.1. If you don't have that version, some minor details will be different (for example, there may not be any floating point arithmetic).

If you are using another dialect of Lisp, you shouldn't have too many problems. In most of the examples, we use a fairly common subset of Lisp functions.


We believe learning should be fun, and this book is written with that philosophy in mind. Thus, at times, we resort to using "cute" examples to keep you from becoming bored with dry material.

We have tried to minimize the difficulties associated with some of the more abstract concepts in Lisp by working up to them from elementary, concrete examples. We suggest that you carefully follow through all the examples presented. Access to your computer is desiderable so that you may try your hand at Lisp; nothing promotes learning like immediate feedback.

The chapters are quite short. It should be possible to read and comprehend several in one sitting. This book was not meant to be read in one sitting, so take your time. There are a few problems at the ends of some of the chapters. Do them if you feel like it. Some of them aren't meant for solution as much as for thought, so if you think about them rather than actually doing them, that's sufficient.


Sometimes (especially in longer examples) in this book you will find that lower case is used to indicate that a line of text is being typed by the user; similarly, upper case denotes lines typed by the Lisp system. If this convention is in use, there is one minor exception to its rule. That is, the letter "L" will always appear in upper case because its lower case form is the same as a one and this might be very confusing in a program example. Unfortunately, L is very often used in Lisp programs to mean "List".

Parenthetical remarks are going to be enclosed in square brackets ["[]"] instead of the normal parentheses because Lisp makes a lot of use of parentheses and things will get confused.


This texti is available with a floppy disk that contains all the functions that we use in this book. Its purpose is to save you typing time and to give you a pre-created environment to write your programs in. If you already know what a Lisp environment is, fine. If not, don't worry about it. It's covered later in the book.


The format of the book is as follow: We start with a chapter of simple examples to get you comfortable with using the Lisp system. We then move into several chapters which introduce the basic data structure and functions. After that, we tell you how to define and edit your own functions. We then introduce the concept of recursion, fundamental to Lisp programming, and spend several chapters exploring different uses of recursion. We lay out a few examples of complicated Lisp programs in detail. The last section of the book consists of some chapters on advanced Lisp techniques, and the guts of the Lisp system itself.

Enjoy, and please feel free to let us know about any problems you have or other things you would like to see.

Contents | Getting Started