Krishnan Ravikumar
Krishnan Ravikumar

Reputation: 295

Racket (Scheme) Error: expected the name of the symbol after the quote, but found a part

I run this code (The Little Schemer) in Dr. Racket Verion 5.3.6:

(define rember
(lambda (a lat)
(cond
  ((null? lat) (quote ()))
  (else 
   (cond
     ((eq? (car lat) a) (cdr lat))
     (else (cons (car lat) (rember a (cdr lat)))))))))

and it throws the error: quote: expected the name of the symbol after the quote, but found a part in (quote ())) part. What is that I am doing wrong here?

Upvotes: 2

Views: 2178

Answers (1)

soegaard
soegaard

Reputation: 31145

The error indicates that you chose to run the program in the "Beginning Student" language. In this language the form quote is restricted.

If you change the language to "Beginning Student with List Abbreviations" everything runs smoothly.

Let's lookup quote in the documentation of the "Beginning Student" language:

The form quote in Beginning Student

You will see that the syntax is described as (syntax name). If you compare this to the documentation of "Beginning Student with List Abbreviations" you will that quote now allows lists to be quoted.

The reason the Beginning Student language is restricted, is that only the form (quote name) is used in the beginning of HtDP, so if a student following HtDP writes '(foo bar) then it is not intentional. Therefore an error (stating that a name is expected) is helpful - consequently the quote form needs to be restricted.

Upvotes: 5

Related Questions