CS 161 Recitation Notes - Lisp Examples
WORK IN PROGRESS, IT MAY STILL BE A BUMPY ROAD TO READ THIS
This document assumes you know the basic list-based structure
of Lisp, as well as the basic arithmetic and list operators
(i.e. +, -, *, car, cdr, cons, list, append), and also the
conditional operator (cond). It attempts to illustrate two
things: the methodology of functional programming using lisp
and how to approach simple AI problems using Lisp. Rather
than just have a long list of code for you to stare at, I've
chosen to show only a few functions, and to annotate thoroughly
how they work and why they are relevant. Additionally, they
try to show you one reasonable prgramming style for your
assignments. Note that every function has a header, and that
the indentation and bracketing of the code is laid out to
make it as readable as possible.
Lisp is a functional programming language. This means
that every Lisp function returns a value, and the ideal
way to program in Lisp is to take advantage of
functionality, rather than relying on side-effects, as
you would in a procedural programming language.