There is a bad mistake in the Question 6 of the exam!
The example shown in incorrect. The result should be:
> (define p (mlist 1 2 3 4 5)) > (make-cumulative! p) > p {1 3 6 10 15}
The value of each element in the result should be the sum of all elements in the original list up to and including that element. So, the first element in the output list is 1 = 1, the second is 1 + 2 = 3, the third is 1 + 2 + 3 = 6, the fourth is 1 + 2 + 3 + 4 = 10, and the fifth is 1 + 2 + 3 + 4 + 5 = 15.
Sorry for the confusion on this. You will receive full credit for this question if your answer either solves the problem as corrected here, or produces the same outputs as the example shown in the original exam.
Special thanks to Caroline Mattey for reporting the problem.
Recent Comments