4 ms·
Because when writing a recursive function, the zero element is generally the base case. if x: <destructure x, recurse on subparts> else:
by chrismonsanto 13y ago
Because when writing a recursive function, the zero element is generally the base case.
if x:
<destructure x, recurse on subparts>
else:
return <something>
This applies to (natural) numbers as well--'destructuring' usually means decrementing the number.