Take a look, compare and contrast with the previous post. Time permitting, I will continue to show you another control poem soon. P.S. See Adding Delimited and Composable Control to a Production Programming Environment for details.
(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)