I’ve always hated recursion. It’s always seemed like a cutesy programming trick that’s not reliable in all conditions.
You could blow the stack in an edge case that you didn’t think of. So it should never be a standard pattern. It’s only good if you need to rewrite something for optimization and recursion is appropriate. But in many cases recursion is slower.
“Look at what I can do in 5 lines of code!” is for programming contests, not for anything important.
I’ve always hated recursion. It’s always seemed like a cutesy programming trick that’s not reliable in all conditions.
You could blow the stack in an edge case that you didn’t think of. So it should never be a standard pattern. It’s only good if you need to rewrite something for optimization and recursion is appropriate. But in many cases recursion is slower.
“Look at what I can do in 5 lines of code!” is for programming contests, not for anything important.