experiments/bidi-generator-example.ss
author Tony Garnock-Jones <tonygarnockjones@gmail.com>
Wed, 16 Jan 2019 17:15:58 +0000
changeset 438 1fe179d53161
parent 283 94f780251884
permissions -rw-r--r--
Add missing primitive implementation for the plain interpreter.

#lang scheme
(require "bidi-generator.ss")

(define (print-all)
  (display "FIRST")
  (newline)
  (do ()
    (#f)
    (display (yield))
    (newline)))

(let ((pa (generator () (print-all))))
  (pa)
  (pa 1)
  (pa 2)
  (pa 3))

(define (yield-four)
  (generator ()
             (yield 1)
             (yield 2)
             (yield 3)
             (yield 4)
             'final-value))

(let ((x (yield-four)))
  (display (x))
  (display (x 'a))
  (display (x 'b))
  (display (x 'c))
  (display (x 'd)))