# [plt-scheme] why isn't DrScheme odd enough?

On Sep 19, Shriram Krishnamurthi wrote:
>* According to the Wadler/Taha/MacQueen paper on even and odd lazy
*>* lists, the following program should produce an error:
*>*
*>* (define (countdown n)
*>* (cons n (delay (countdown (- n 1)))))
*>*
*>* (define (dmap f l)
*>* (if (null? l)
*>* l
*>* (cons (f (car l))
*>* (delay (dmap f (force (cdr l)))))))
*>*
*>* (define (cutoff n l)
*>* (cond
*>* ((= n 0) '())
*>* ((null? l) '())
*>* (else (cons (car l)
*>* (cutoff (- n 1) (force (cdr l)))))))
*>*
*>* (cutoff 5 (dmap sqrt (countdown 4)))
*>*
*>* In fact, it does no such thing. I wondered whether DrScheme had
*>* adopted "even" laziness somewhere along the way, so I switched to R5RS
*>* Scheme (hence the lack of brackets, etc., above) and ditto.
*>*
*>* Anyone spot what I'm missing?
*
Yes, (sqrt -1) is not an error in mzscheme... This is the surprise
they're describing:
> (cutoff 4 (dmap values (countdown 4)))
(4 3 2 1)
> (cutoff 4 (dmap / (countdown 4)))
/: division by zero
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!