Exercise 3.81. Exercise 3.6 discussed generalizing the random-number generator to allow one to reset the random-number sequence so as to produce repeatable sequences of ``random'' numbers. Produce a stream formulation of this same generator that operates on an input stream of requests to generate a new random number or to reset the sequence to a specified value and that produces the desired stream of random numbers. Don't use assignment in your solution. ———————————————————————————————————————————————————————————————————————— 3.6 solution: (define rand (let ((x random-init)) (lambda (m) (cond ((eq? m 'reset) (lambda (y) (set! x y))) ((eq? m 'generate) (set! x (rand-update x)) x) (else (error "hm...")))))) stream-based: (define (rand request-stream) (define (f last-result last-request) (cond ((eq? last-request 'generate) (rand-update last-result)) ((pair? last-request) (rand-update (cadr last-request))))) (define results (cons-stream random-init ; defined elsewhere, as above (stream-map f results request-stream))) results) The stream of requests should contain requests that are either the symbol "generate" or a list ('reset x) where x is the value to set.