[plt-scheme] call/cc puzzle

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Sat Jan 17 18:04:49 EST 2009

Henk Boom wrote:
> 2009/1/17 Jos Koot <jos.koot at telefonica.net>:
>> Is that a quation or just a nice gesture?
>> Jos
> 
> The latter. I had fun coming up with it and figuring out why it did
> what it did, and I thought maybe other people would as well. =)

Now you are warm, try Eugene Kohlbecker's mind-bender called
Mondo Bizarro. It is a Scheme classic.


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

-- 
Jens Axel Søgaard


Posted on the users mailing list.