我正在學習Scheme並使用一些示例來查看工作內容。計劃中的SHOW/READ/READ-LINE/etc程序
我正在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等發生同樣的事情。
謝謝!
我真的不進的小寵物^ W方案,但它'display',而不是'show'? – 2013-02-13 19:58:00
不,我從這裏得到了這個例子:http://www.eecs.berkeley.edu/~bh/ssch20/io.html – user1060551 2013-02-13 20:09:58
該章引述:「事實上,show不是官方的Scheme原語,我們根據顯示和換行編寫了它。「 – 2013-02-13 20:12:55