私は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なども同様です。
ありがとう!