April 2018
Intermediate to advanced
408 pages
10h 42m
English
We can consider the sum() function to have the following kind of definition:
We could say that the sum of a collection is 0 for an empty collection. For a non-empty collection the sum is the first element plus the sum of the remaining elements.

Similarly, we can compute the product of a collection of numbers recursively using two cases:

The base case defines the product of an empty sequence as 1. The recursive case defines the product as the first item times the product of the remaining ...