Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting an unbound error for "atom?"

I'm trying to go through "The Little Lisper" and already running into snags in the first chapter. I'm relatively new to Emacs (which has fueled my interest in learning Lisp and clojure). I downloaded the Mit-scheme app, and am working the exercises on Edwin.

I'm trying:

(atom? (cons a l))

where a is an atom and l is a list already defined. I get the following error:

;Unbound variable: atom?

Why? I have no problems using the "null?" function. I thought "atom?" is an internal function checking to see if the value returned is an atom.

Any explanation would be much appreciated. I still haven't set up my emacs to run scheme, and the minor differences between all the lisp dialects is testing my patience.

like image 841
Tavore Avatar asked Jun 05 '13 06:06

Tavore


2 Answers

In "The Little Schemer" ("The Little Lisper"'s updated version) the atom? procedure is defined as follows (because atom? doesn't exist in Scheme):

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

If you're following an old version of the book, I advise you to either look for a newer version or use the same programming language used in the book: Common Lisp for The Little Lisper, Scheme for The Little Schemer - and Racket is a great Scheme IDE to work with! take a look at this answer for some tips when going through The Little Schemer using Racket.

like image 176
Óscar López Avatar answered Nov 15 '22 10:11

Óscar López


I'm trying to go through "The Little Lisper"... I downloaded the Mit-scheme

Common Lisp and Scheme are very different languages.

You have to either use a different book (e.g., SICP) to match your language implementation or a different language implementation (e.g., clisp or sbcl) to match your book.

like image 27
sds Avatar answered Nov 15 '22 09:11

sds