naive generators added by ari on Thu Nov 26 20:16:49 2020
;; naive implementation (define (make-generator transformer start #!optional (retriever identity) #!rest args) (let ((next start)) (lambda () (let ((yield next)) (set! next (apply transformer (cons next args))) (retriever yield))))) (define (list->generator ls) (make-generator (lambda (x) (if (pair? x) (cdr x) #!eof)) ls (lambda (x) (if (pair? x) (car x) #!eof)))) ;; naive usage (define listgen (list->generator '(a b c d))) (define iotagen (make-generator add1 0))