Reply to comment
Exercse 1.32
Show that
sumandproduct(exercise 1.31) are both special cases of a still more general notion calledaccumulatethat combines a collection of terms, using some general accumulation function:(accumulate combiner null-value term a next b)Accumulatetakes as arguments the same term and range specifications assumandproduct, together with acombinerprocedure (of two arguments) that specifies how the current term is to be combined with the accumulation of the preceding terms and anull-valuethat specifies what base value to use when the terms run out. Writeaccumulateand show howsumandproductcan both be defined as simple calls toaccumulate.If your
accumulateprocedure generates a recursive process, write one that generates an iterative process. If it generates an iterative process, write one that generates a recursive process.
