2

我在 Dr. Racket Verion 5.3.6 中运行此代码(The Little Schemer):

(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)))))))))

它抛出错误:部分quote: expected the name of the symbol after the quote, but found a part(quote ()))我在这里做错了什么?

4

1 回答 1

5

该错误表明您选择以“初学者”语言运行程序。在这种语言中,形式quote受到限制。

如果您将语言更改为“Beginning Student with List Abbreviations”,一切都会顺利进行。

quote让我们在“初学者”语言的文档中查找:

quote初中生的形式

您将看到语法被描述为(syntax name). 如果您将此与“Beginning Student with List Abbreviations”的文档进行比较,您quote现在将允许引用列表。

初学者语言受到限制的原因是,(quote name)在 HtDP 的开头只使用了表格,所以如果一个跟随 HtDP 的学生写'(foo bar),那么它不是故意的。因此,错误(说明需要名称)是有帮助的 - 因此quote需要限制表单。

于 2014-09-02T08:57:29.567 回答