Earlier quoted context omitted.
> Nobody has yet convinced me that recursion has any sustained advantage over looping. Looping may require trampolining or defunctionalisation, whilst recursion can be written much more directly and simply. As a very simple example (in pseudocode): even(n: uint): boolean = n match { case 0: true case n: odd(n-1) } odd(n: uint): boolean = n match { case 0: false case n: even(n-1) } Whilst these are pretty silly implem…
I'm not going to argue this is good, but it's fairly analogous: boolean isEven(int n) { boolean even = true; for (; n > 0; --n) even = !even; return even; }
- Updates and bug-fixes to the `isOdd` function will not be inherited by your `isEven` function.
- If I set a breakpoint in this function, it won't get triggered when I call `isOdd`.
- Your `isEven` function requires an implementation of `!`
- etc.