3 ms·
I see, so the point you wanted to draw was that if you wanted to implement two functions, mutual recursion might let you separate the implementation logic. That
by roenxi 4y ago
I see, so the point you wanted to draw was that if you wanted to implement two functions, mutual recursion might let you separate the implementation logic. That is a nice trick.
> you've changed the semantics and engineering tradeoffs so much that we might as well write `n % 2 == 0`.
That is a fairly glaring weakness of the example you've chosen - it is taking a simple situation and overthinking it. It doesn't really matter because I see your point and surely one would exist, but do you have an example where this technique is an efficient solution?
- chriswarbo 4y agoYes, exactly :) Again, it's not always "better", but it's a situation that doesn't seem to map directly to a loop. I gave a more complicated, realistic example in a sibling comment https://news.ycombinator.com/item?id=35466256 https://news.ycombinator.com/item?id=35466256