4 ms·
>In my experience, telling them to "just trust it" and such seems to not help much. I've sometimes got past the "leap of faith" step by replacing the recursive
by clusmore 9y ago
>In my experience, telling them to "just trust it" and such seems to not help much.
I've sometimes got past the "leap of faith" step by replacing the recursive call with a call to a built-in. e.g.
>>> sum([1, 2, 3, 4]) == 10
True
>>> def my_sum(xs):
... if xs == []: return 0
... else: return xs[0] + sum(xs[1:])
>>> my_sum([1, 2, 3, 4]) == 10
It's often easier to accept this definition, because trusting that the built-in will work is comparatively simple. You then ask the audience what would happen if you replaced the call to the built-in with a recursive call.
Edit: It appears I've written an identical comment to my sibling.