Created
August 22, 2019 00:40
-
-
Save rileylev/31264dabdf9935a42255216abb6b6ea3 to your computer and use it in GitHub Desktop.
using prompts (delimited continuations) to build generators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define yield (prompt-tag)) | |
(define (count-helper) | |
(let loop ((n 0)) | |
(abort-to-prompt yield n) | |
(loop (1+ n)))) | |
(define this-step count-helper) | |
(define (count) | |
(call-with-prompt yield | |
this-step | |
(lambda (next-step result) | |
(set! this-step next-step!) | |
result))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment