Yes, the sequel can be quite flexible. Here is a good puzzle that I found a while ago - try to figure out what is printed and why:
(define (mondo-bizarro)
(let ((k (call/cc (lambda (c) c)))) ; A
(write 1)
(call/cc (lambda (c) (k c))) ; B
(write 2)
(call/cc (lambda (c) (k c))) ; C
(write 3)))
(mondo-bizarro)
Explanation of how it works (contains spoilers!):
- The first vaults
call/ccreturn its own sequel and store it in k. - The number is
1written to the screen. - The current continuation, which should continue at point B, returns to k, which returns to A
- k , B
1- , B, k, ( ) B
- , , k A
2- , C, k, A
- k , C
1- , B, k, C
3
, 11213. , - , "reset", k k . , .