Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Created January 14, 2015 18:34
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 glenjamin/cd76f59d9a56be903747 to your computer and use it in GitHub Desktop.
Save glenjamin/cd76f59d9a56be903747 to your computer and use it in GitHub Desktop.
scheme tinkering
(define (f yield)
(yield 1)
(yield 2)
(yield 3))
(define gen
(letrec ((pause '())
(resume '())
(yield (lambda (x)
(call/cc (lambda (k)
(set! resume k)
(pause x))))))
(lambda ()
(call/cc
(lambda (k)
(set! pause k)
(if (null? resume)
(f yield)
(resume '())))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment