灯下 登录
计算机科学 / SICP / 3.5.5 Modularity of Functional Programs and Modularity of Objects

Exercise 3.81 · 习题

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.81:练习 3.6 讨论了对随机数生成器的推广,允许重置随机数序列以产生可重现的"随机"数序列。请对同一生成器给出流的表述,使其作用于一个请求流——请求可以是生成一个新随机数,或将序列重置到指定值——并产生所需的随机数流。解法中不得使用赋值。