Code and comments

Practical and theoretical aspects of software development

Getting started with The Little Schemer

Every programmer should read The Little Schemer (pdf) at some point. It doesn’t take long to read, and I hope to provide a review of it soon. For now, I hope to explain how to get started practically with Scheme, as used in this book, since these details are hard to find.

For a Scheme interpreter, I recommend guile. The standard choice is mit-scheme but:

  1. It isn’t available by default to apt-get install in Ubuntu 11, though it is in Ubuntu 10.
  2. It wasn’t obvious how to use it in Cygwin. For more about installing things in Cygwin, read here.
  3. I didn’t want to re-enter the emacs world, having spent considerable time using Vim lately.

I managed to get mit-scheme on my windows machine before, when I was first looking at SICP but the experience left me thinking that the support for mit-scheme was falling by the wayside, probably due to changes at MIT, such that Scheme is no longer taught to all CS students.

Once you have guile, you can get started, but it won’t be too long until you are annoyed. Guile is an interactive interpreter, and as you try to type in longer functions, and make parenthesizing mistakes, you will wish for a text-editor. And then you will wonder how to make your functions available in an interactive sessions. Here’s all you need:

guile> (load "")

Finally, there are three functions regularly used in The Little Schemer that are not part of the Scheme language. You won’t want to type these in each interactive session, so make a file called with the following code:

(define atom?
  (lambda (x)
    (and (not (pair? x)) (not (null? x)))))

(define add1
  (lambda (x)
    (+ x 1)))

(define sub1
  (lambda (x)
    (- x 1)))

Now just start each interactive session with (load ""). Make other source files as necessary. And have fun.


Written by Eric Wilson

September 1, 2011 at 9:52 am

Posted in how-to

Tagged with , , ,

4 Responses

Subscribe to comments with RSS.

  1. The Little Schemer is written by Dan Friedman at Indiana University (another hub of Scheme knowledge, like MIT is) and the Scheme interpreter/compiler developed there (by Kent Dybvig, et al.) is also available for download on the web, at the URL below. The compiler (Chez Scheme) costs money, but the interpreter (Petite Chez Scheme) is free.
    I’ve been told that it’s the fastest Scheme interpreter/compiler out there, but I haven’t checked.
    The particular relevance here, however, is that it has the add1, sub1, and atom? predicates built-in. The load command still works as in this blog post, too.


    September 1, 2011 at 11:40 am

    • Thanks much! I had noticed Dr. Friedman was a professor at IU, but I didn’t think to look for resources there. I also didn’t realize IU was a “hub of Scheme knowledge,” despite my time in the math department there.

      So the obvious question is: can you apt-get install petite-chez-scheme? That question addressed here:

      As for Cygwin, petite-chez-scheme is not one of the standard packages that can be installed, and a quick googling did not reveal how it might be done.

      Eric Wilson

      September 1, 2011 at 1:01 pm

  2. […] don’t be lazy, if you are going to read this book, set up an interpreter, and start […]

  3. You could also consider using Racket (, which has a very nice IDE called DrRacket as part of the installation. You can get the latest version from the website, but there’s also a ppa for Ubuntu ( if you prefer to install via the repositories.

    Ian Gibson

    August 10, 2012 at 9:40 pm

Comments are closed.

%d bloggers like this: