Skip to content

Instantly share code, notes, and snippets.

@agumonkey
Forked from anonymous/nested-cont.scm
Created August 18, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agumonkey/529122d25949f3a75798f13313c427e2 to your computer and use it in GitHub Desktop.
Save agumonkey/529122d25949f3a75798f13313c427e2 to your computer and use it in GitHub Desktop.
nested continuations are tricky (see Alan Bawden)
(define (cc k) (call-with-current-continuation k))
(display (format ">>> ~s\n" (- 10 (cc (lambda (k) (+ 1 (+ 2 (k 10))))))))
(let ((k (cc (lambda (bind) (lambda (x) (+ 1 (cc (lambda (k) (bind k))))))))) (k 10))
(let ((k (cc (lambda (bind)
(lambda (x)
(+ 1 (cc (lambda (k)
(bind k)))))))))
(k 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment