coroutines added by anandamide on Thu Mar 31 17:39:00 2016

(define (range-gen str stp inc)
  (call/cc
   (lambda (yield)
     (yield (lambda ()
	      (let ([i str])
		(cond ([< str stp]
		       (set! str (+ i inc))
		       i)
		      (else #f))))))))

(define continue? (range-gen 0 20 1))
(define it (range-gen 0 20 1))
    
(define (routine-a cc)
  (let loop ()
    (cond ((continue?)
	   (printf "Blah ~A~N" (it))
	   (set! cc (call/cc cc))
	   (loop)))))

(define (routine-b cc)
  (let loop ()
    (cond ((continue?)
	   (printf "Blar ~A~N" (it))
	   (set! cc (call/cc cc))
	   (loop)))))