2 ms·
That task here is: A 'compute-slopes' function gets a list of points and returns a list of slops between consecutive points. The problem: What if points have t
by qznc 14y ago
That task here is: A 'compute-slopes' function gets a list of points and returns a list of slops between consecutive points.
The problem: What if points have the same x-value, hence the slope is undefined.
Solution 1 Exceptions: throw new DivisionByZero()
Solution 2 Condition Handling: provide the restarts point to (a) return nil, (b) return 0, and (c) return a user-specified value.
Solution 3 Return Error: return Error("division by zero")