exercise 1.32: generalizing sum and product to 'accumulate'