2 ms·
Your first example is actually a tail call. It's just a tail call to the || operator. Every function has a tail call by definition.
by eru 16y ago
Your first example is actually a tail call. It's just a tail call to the || operator. Every function has a tail call by definition.
- eru 16y agoAnd the next two examples are tail calls of even and odd thanks to shortcutting of ||.
- raganwald 16y agoAbsolutely the calls to even and odd are tail calls because of the semantics of || in Ruby (and most other languages). I hope we agree that even and odd are still mutually tail recursive, because Mutual Tail Recursion is a special case of tail calling.