简体   繁体   English

球拍(方案)错误:引用后应使用符号名称,但找到了一部分

[英]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: 我在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. 并引发错误: quote: expected the name of the symbol after the quote, but found a part(quote ()))部分中quote: expected the name of the symbol after the quote, but found a part一部分。 What is that I am doing wrong here? 我在这里做错了什么?

The error indicates that you chose to run the program in the "Beginning Student" language. 该错误表明您选择了以“ Beginning Student”语言运行程序。 In this language the form quote is restricted. 在这种语言中,形式quote受限制。

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: 让我们在“入门学生”语言的文档中查找quote

The form quote in Beginning Student quote中的表格quote

You will see that the syntax is described as (syntax name) . 您将看到该语法描述为(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. 如果将其与“使用列表缩写的学生入门”的文档进行比较,则该quote现在将允许引用列表。

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. 限制初学者使用语言的原因是,在HtDP的开头仅使用了形式(quote name) ,因此,如果遵循HtDP的学生写了'(foo bar)则它不是故意的。 Therefore an error (stating that a name is expected) is helpful - consequently the quote form needs to be restricted. 因此,错误(指出需要使用名称)是有帮助的-因此, quote单形式必须受到限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM