Exercise 3.76: Eva Lu Ator has a criticism of
Louis’s approach in Exercise 3.75. The program he wrote is not modular,
because it intermixes the operation of smoothing with the zero-crossing
extraction. For example, the extractor should not have to be changed if Alyssa
finds a better way to condition her input signal. Help Louis by writing a
procedure smooth that takes a stream as input and produces a stream in
which each element is the average of two successive input stream elements.
Then use smooth as a component to implement the zero-crossing detector
in a more modular style.
练习 3.76:Eva Lu Ator 对 Louis 在练习 3.75 中的做法提出了批评。他所写的程序不具有模块性,因为它将平滑操作与零交叉点提取操作混在一起了。例如,如果 Alyssa 找到了更好的输入信号调理方法,提取器就不应该需要改变。请帮助 Louis,写一个过程 smooth,它以一个流为输入,产生一个流,其中每个元素是输入流中相邻两元素的平均值。然后将 smooth 用作组件,以更具模块性的风格实现零交叉检测器。