I have this problem to work on:
A more comprehensive procedure of a higher order can be generalized even further to catch the idea of combining terms with a fixed operator. The mathematical product operator is a concrete example of this idea, with multiplication replacing the addition of the sum operator. The accumulation procedure begun below is intended to capture this idea. A combiner parameter is an operator that is used to abbreviate terms, and a base parameter is a value that is returned when there are no remaining conditions for combining. For example, if we had already completed the accumulation procedure, then we could define the summation procedure as:
(determine the amount (copy + 0))
Complete the definition of accumulation so that it is maintained in accordance with this description.
(define accumulate
(lambda (combiner base)
(lambda (term start next stop)
(if (> start stop)
...
...))))
I inserted as the last two lines:
base
(combiner base (accumulate (combiner start stop) start next stop))
but I have no idea whether this is correct and how to actually use the summation procedure to accumulate and therefore sum the numbers.
source
share