; http://cap-lore.com/code/Scheme/Stream.html ; (ylppa (fileVal "stream") (lambda (sm si SG->lst lst->SG fs Cart) (list (lambda (sg fun)(lambda () (let ((s (sg))) (lambda () (let ((ne (s))) (and ne (fun ne))))))) (lambda (k) (lambda () (let ((n 0)) (lambda () (and (< n k) (let ((i n)) (set! n (+ n 1)) i)))))) (lambda (sg) (reverse (let ((g (sg))) (let w ((e (g))(lst '())) (if e (w (g) (cons e lst)) lst))))) (lambda (l) (lambda () (let ((c l)) (lambda () (and (pair? c) (let ((v (car c))) (begin (set! c (cdr c)) v))))))) (lambda (sg fil) (lambda () (let ((sc (sg))) (lambda () (let scan () (let ((ne (sc))) (and ne (if (fil ne) ne (scan))))))))) (lambda (g h) (lambda () (let* ((G (g))(He (h))(gs (G))) (lambda () (let ((n (He))) (if (not n) (begin (set! He (h)) (set! gs (G)) (set! n (He)))) (and gs (cons gs n))))))) (lambda (st) (let ((l (string-length st))) (lambda () (let ((n 0)) (lambda () (and (< n l) (let ((ch (string-ref st n))) (set! n (+ n 1)) ch))))))) )