This repository contains solutions that I have written to a few of the exercises from the book ANSI Common Lisp by Paul Graham. The book came out in year 1996, and is an interesting read today (year 2021) as well, in my opinion.
pg, as you may know, was one of the co-founders of Y Combinator, the first of a new type of startup incubator. Prior to that he co-founded Viaweb, in 1995. They wrote Viaweb partially in Lisp.
pg has written a couple of other books as well, including Hackers & Painters: Big Ideas from the Computer Age. This other book I have read also and I enjoyed that one too.
You can read reviews and stuff about the book ANSI Common Lisp here:
https://www.goodreads.com/book/show/41801.ANSI_Common_Lisp
And you can see the Amazon listing for the book here (affiliate link):
ANSI Common Lisp listing on Amazon
You will probably want to buy it used. That's what I did. I mean, it's a good book, but I don't think almost any book should cost you >$100 USD in 2021-dollars. Somewhere between $15 and $45 is a fair price in 2021-dollars for most good books.
Buying it used from Amazon you can get it at a decent price. Buying it new from Amazon will cost you over $100 at the moment. So yeah, buy it used somewhere. Either at Amazon or someplace else.
All the solutions include a comment at the start of the file, with a reproduction of the assignment text so that it makes sense to the reader what the program is trying to do without having to consult with the paperback copy of the ANSI Common Lisp book.
Exercise solutions are named according to chapter and exercise number.
Before attempting to run any of the solutions, please ensure that you have the necessary dependencies installed on your computer. You can find a list of dependencies that need to be installed in the section titled Prerequisites, below.
Run any of the solutions, e.g.:
./e-10-1.cl
-
e-11-2.cl
produces a file namedspheres.pgm
as its output. The PGM format is a lowest common denominator grayscale file format. It is designed to be extremely easy to learn and write programs for. See http://netpbm.sourceforge.net/doc/pgm.html for details about the PGM format.On macOS you can
open spheres.pgm
or double-click on it and by default it will open in Preview where you can view it. On other platforms there are programs that allow you to view PGM files as well. Look up the details for your platform online.
The following dependencies need to be installed in order to run the code in this repository and in order to be able to view the generated output:
- Steel Bank Common Lisp
- Graphviz
The subsections that follow explain how to install these dependencies on some common Unix operating systems, including macOS, FreeBSD and some popular Linux distros.
Assuming you have Homebrew installed:
brew install sbcl graphviz
(The command below needs to be run as root, I recommend using doas
to execute commands as root.)
pkg install sbcl graphviz
Use the package manager or other type of preferred installation method that they use on your distro. Here's how to do it for some of the most common Linux distros.
sudo apt-get install sbcl graphviz
sudo dnf install sbcl graphviz
sudo zypper install sbcl graphviz
Package sbcl
is not available for openSUSE Leap 15.3 at the time of this
writing according to https://software.opensuse.org/package/sbcl
Package graphviz
is not available for openSUSE Leap 15.3 at the time of this
writing according to https://software.opensuse.org/package/graphviz
sudo pacman -S sbcl graphviz
emerge --ask dev-lisp/sbcl media-gfx/graphviz