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

I'm trying to get through the Little Lispper and have already run 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-schem app and am working on exercises on Edwin.

I'm trying to:

(atom? (cons al)) 

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

 ;Unbound variable: atom? 

Why? I have no problem using "null"? function. I thought "atom"? is an internal function that checks if the return value is an atom.

Any explanation would be greatly appreciated. I still haven't configured emacs to run the circuit, and the slight differences between all the Lisp dialects test my patience.

+4
source share
3 answers

In the "Little Scheme" (an updated version of the "Little Lispper") is the atom? procedure atom? is defined as follows (since atom? does not exist in the diagram):

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

If you follow the old version of the book, I suggest you either look for a newer version or use the same programming language used in the book: Common Lisp for Little Lisper, Scheme for the Little Schemer - and Racket - a great IDE scheme for working! look at this answer for some tips when going through Little Schemer using Racket.

+3
source

I'm trying to get through the Little Lisp ... I downloaded the Mit Schema

General Lisp and schema are very different languages.

You need to either use another book (e.g. SICP ) to match the language implementation or another language implementation (e.g. clisp or sbcl ) according to your book.

+2
source

Take a look at Scheme R5RS ; It includes a list of functions and syntax keywords. Although this scheme is not part of the Scheme standard, the mit scheme has an apropos function that will find functions (other things) with the given name. try:

 (apropos "atom") 

(but will not show anything :-).

An atom is something that is not a "cons cell" (usually if I remember my CommonLisp). In a schema, you can implement it as:

 (define (atom? thing) (not (pair? thing))) 

Note: is this the definition of atom? Corresponds to CommonLisp atom .

+1
source

Source: https://habr.com/ru/post/1484566/


All Articles