control, resumed
Since at least some people helped me re-re-invent prompt after my last post, I thought I would remind people that PLT Scheme is the only production system in the world that provides delimited and (truly) composable continuations directly (and w/o loss of TCO properties). So here is the same fragment again:
(require (lib "control.ss")) (define (generate-one-element-at-a-time a-list) (define (control-state) (for-each (lambda (an-element-from-a-list) (control resume-here (set! control-state resume-here) an-element-from-a-list)) a-list) 'you-fell-off-the-end-off-the-list) (define (generator) (prompt (control-state))) generator)
0 comments:
Post a Comment