3

私は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なども同様です。

ありがとう!

4

2 に答える 2

5

show手順は定義されていません。チキンスキームに実装されたR5RSの一部として、ドキュメントdisplayに示されているように、またはwrite出力に使用できます。

ただし、の機能はshow簡単に実装できます。

(define (show obj)
  (display obj)
  (newline))
于 2013-02-13T20:14:10.573 に答える
0

チキンの名前はshowですprint。使用する場合 (define show print) は、どちらの名前も使用できます

于 2016-08-23T11:05:22.657 に答える