NOTE 1: Check all Lisp code with the Unit Tester and the Lisp Critic before submitting. Even when there are no unit tests, all code can and should be checked with the Lisp Critic. If I notice mistakes in code that the Critic catches, I stop reviewing immediately and return the code.

NOTE 2: Define all functions in a file, using a Lisp editor. Code typed in the Listener window, or edited in an plain text editor like Sublime, will be incorrectly indented. Such code will be returned unreviewed for proper indentation.

NOTE 3: Check all JavaScript exercises with the CS325 JS tester. If at all possible, enable ESLint with Airbnb in your JavaScript editor, e.g., Atom, Brackets, Sublime 3, TextMate, Visual Studio Code.


This course is about several different ways to represent and use symbolic knowledge representations to answer questions and solve problems. We will cover three major approaches to representing and using everyday knowledge. Along the way, we will also explore some of the technologies used to share knowledge of the web.

Don't panic if some section takes you longer than you expected. But do panic if your productivity falls below what I expect. Make sure you understand how this course works.

Exercise Bundles

Exercises are small coding problems. Like calisthenics, they help you focus on and strengthen specific "coding muscles." Exercises are more focused on a specific coding challenge, and have very thorough unit tests.

Applications are larger coding problems, requiring you to master and apply multiple coding skills and basic AI concepts to do something useful. There are fewer unit tests, and they are there only to verify that the overall system works for some basic examples.

The exercises and applications below are organized into topic bundles. The exercises in a bundle prepare you for the applications in that bundle.

A number of older exercises are not in any bundle right now. You can do them for practice if you want, but don't submit them to Code Critic. Email me if you want help on a non-bundled exercise.


Exercises are where I do the most critiquing of the quality of your code. There is too much bad code in the real world because developers never learned to write clean solid code in the small.

Applications are where I evaluate how well you have learned to program. I critique them but not in as much detail.

If you think a critique does not apply, include a comment with the critique, and why you think it doesn't apply in this case. As soon as I see code that gets a Lisp Critic critique without such a comment, I stop reviewing and return the code for re-work.

The Bundles

When doing exercises from Graham, be sure to read both the book's requirements, and my notes.

Sequence Functions Bundle

There are both Lisp and JavaScript exercises here. Iterating over sequences is pretty basic, but if iteration means while and for, you have a lot to learn.

Recursion Bundle

Recursion is central to AI Programming, for numerous tasks, including

Time to stop thinking recursion is a funky way to implement factorial!

Text Processing Bundle

In our code, we pass and return values, so reading and printing are not needed as much as you may be used to. But text processing does become important when analyzing linguistic input or passing data over the web.

Pattern Matcher Bundle

Do not do these until we have talked about the pattern matcher in class. These exercises extend the pattern matcher defined in class quizzes. You need to match.lisp to do these.

Trie Bundle

Tries (pronounced like "trees" as in re-trie-val) are a specializaed recursive data structure that can pay off with big speed up in code, when appropriately used.

Multiple Values and Continuations Bundle

Lisp has a special facility for efficiently returning multiple values from code without creating temporary lists that need to be garbage collected.

Numeric Application Bundle

Lisp is not thought of as a language for numeric processing, but it actually does quite well. With type declarations and adjustment of the compiler's options, numeric Lisp code can be competitive with C++.

The applications here are easy to understand, but are surprisingly hard to solve with clean readable code.

Deductive Retrieval Bundle

Don't do these until we have discussed deductive retrieval in class. Deductive retrieval, i.e., retrieving data deductively inferred from other data, is surprisingly simple to implement, surprisingly powerful, but hard to optimize.

Generated Lists Bundle

Want to have an infinite list? Or a list of future values? Here's one simple way to do it. For even more on this idea, see the ReactiveX API.

Cleaning Up Legacy Code Bundle

Why do I spend so much time getting you to write 10 line functions as cleaner shorter 3 line functions? Because if you don't nip certain coding practices in the bud, you end up with the code in the joke generator in the applications.

Semantic Web Bundle

Wait until we've discussed triples in class.

Macro Bundle

Macros are a super-simple way to extend Lisp syntax. Having said that, extending the syntax of a language can lead to hard to maintain code. Use with caution.

Faculty: Chris Riesbeck
Time: Monday, Wednesday, Friday: 11am - 11:50am
Location: Tech LR5


Important Links