Mondo Bizarro

In this thread about a closure puzzler Jens posted Eugene Kohlbecker’s mind-bender called Mondo Bizarro.


;;; Mondo Bizarro

; What does the following program print?
; Why?

(define program (lambda ()
    (let ((y (call-with-current-continuation (lambda (c) c))))
         (display 1)
         (call-with-current-continuation (lambda (c) (y c)))
         (display 2)
         (call-with-current-continuation (lambda (c) (y c)))
         (display 3))))


(program)

Mondo Bizarro seems to have been originally published in ACM SIGPLAN Lisp Pointers, Volume 1, Issue 2 (June-July 1987), located here; but I could not confirm that.

Here is an implementation of it in Java.

(via the PLT Discussion List)

One thought on “Mondo Bizarro”

Leave a Reply

Your email address will not be published. Required fields are marked *