まずコルーチンを実装します。 Scheme は継続(Continuation)を扱えるので、簡単にコルーチンを実装できます。 (use util.queue) (define *tasks* (make-queue)) (define-syntax define-coroutine (syntax-rules () ((_ (routine yield) body ...) (define (routine) (call/cc (lambda (return) (define (yield) (call/cc (lambda (cont) (enqueue! *tasks* cont) (re…