user1060551
user1060551

Reputation: 431

SHOW/READ/READ-LINE/etc procedures on Scheme

I am learning Scheme and using some examples to see the stuff working.

I am using Chicken interpreter with Eclipse.

When trying to run the following code:

(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)

And I am getting the following error:

#;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)))) <--

Does anybody knows why? Of course if I create a procedure that says "show" will display stuff, then it works, but should SHOW be a standard procedure from Scheme? Because many codes through internet shows like that and there is no "show" procedure description. The same thing happens to READ/READ-LINE and etc.

Thanks!

Upvotes: 3

Views: 273

Answers (2)

Sandra
Sandra

Reputation: 247

Chicken's name for show is print. If you do (define show print) you can use either name

Upvotes: 0

&#211;scar L&#243;pez
&#211;scar L&#243;pez

Reputation: 236114

The show procedure is not defined. As part of the R5RS implemented in Chicken Scheme, you can use display or write for output, as shown in the documentation.

The functionality of show can be easily implemented, though:

(define (show obj)
  (display obj)
  (newline))

Upvotes: 5

Related Questions