gpt4 book ai didi

scheme - Racket (方案)错误: expected the name of the symbol after the quote,但找到了零件

转载 作者:行者123 更新时间:2023-12-02 09:36:27 24 4
gpt4 key购买 nike

我在 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:预期在引号后出现符号名称,但在 (quote ()))< 中找到了一部分/ 部分。我在这里做错了什么?

最佳答案

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

如果您将语言更改为“使用列表缩写的初学者”,一切都会顺利进行。

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

The form quote in Beginning Student

您将看到语法被描述为(语法名称)。如果您将其与“初学者使用列表缩写”的文档进行比较,您会发现 quote 现在允许引用列表。

初级学生语言受到限制的原因是,在 HtDP 的开头仅使用 (quote name) 形式,因此如果遵循 HtDP 的学生写 '(foo bar ) 那么这不是故意的。因此,错误(指出需要名称)很有帮助 - 因此需要限制 quote 形式。

关于scheme - Racket (方案)错误: expected the name of the symbol after the quote,但找到了零件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25618970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com