我正在学习 Scheme 并使用一些示例来查看这些东西是否有效。
我在 Eclipse 中使用 Chicken 解释器。
尝试运行以下代码时:
(define (bottles n)
(if (= n 0)
'burp
(begin (verse n)
(bottles (- n 1)))))
(define (verse n)
(show (cons n '(bottles of beer on the wall)))
(show (cons n '(bottles of beer)))
(show '(if one of those bottles should happen to fall))
(show (cons (- n 1) '(bottles of beer on the wall)))
(show '()))
(bottles 3)
我收到以下错误:
#;1> #;2> Note: the following toplevel variables are referenced but unbound:
verse (in bottles)
#;3> #;3> Note: the following toplevel variables are referenced but unbound:
show (in verse) show (in verse) show (in verse) show (in verse) show (in verse)
Error: unbound variable: show
Call history:
<syntax> (bottles 3) <eval> (bottles 3) <eval> [bottles] (= n 0) <eval> [bottles] (verse n) <eval> [verse] (show (cons n (quote (bottles of beer on the wall)))) <--
有人知道为什么吗?当然,如果我创建一个说“show”将显示内容的程序,那么它可以工作,但是 SHOW 应该是 Scheme 的标准程序吗?因为互联网上的许多代码都是这样显示的,并且没有“显示”程序描述。READ/READ-LINE 等也会发生同样的事情。
谢谢!