(load "streams.ss") (define ones (cons$ 1 ones)) ; stream of 1's (define ints (cons$ 1 (+$ ones ints))) ; stream of positive ints (define randoms ; (randoms 10) gives stream of (lambda (n) ; random digits (cons$ (random n) (randoms n)))) (define random-chars ; (random-chars) is a stream of (lambda () ; random characters (cons$ (integer->char (+ (random 26) (char->integer #\a))) (random-chars)))) (define keyboard-stream ; (keyboard-stream) is a stream (lambda () ; of s-expressions typed by the (display "? ") ; user (let ((this (read))) (if (eq? this 'eof) 'the-empty-stream (cons$ this (keyboard-stream))))))