I'm in the process of learning Scheme. I recently spent (too much!) time trying to find a bug in a program before I realized I was missing the 'else' word in a cond clause. But the behavior in such circumstances appears to be a little weird. Experimenting with the conditions with just a simple program (below) the 'whatever' gets displayed as expected in the else clause, but also gets displayed, but without the 'else', gets displayed with the surrounding double quotes and the un-interpreted new line printed literally. Can anybody explain to me what's happening? TIA.
(define (foo x)
(cond ((eq? x 0) (display "zero\n"))
(display "whatever\n")))
(define (bar x)
(cond ((eq? x 0 ) (display "zero\n"))
(else (display "whatever\n"))))
In the repl window:
Welcome to DrScheme, version 4.1.5 [3m].
Language: Pretty Big; memory limit: 128 megabytes.
> (foo 0)
zero
> (bar 0)
zero
> (foo 2)
"whatever\n"
> (bar 2)
whatever
>