4 ms·
I find that recursion is something that in simple cases can be replaced with a loop, and in complex cases is hard to reason about and therefore should be avoide
by Koshkin 4y ago
I find that recursion is something that in simple cases can be replaced with a loop, and in complex cases is hard to reason about and therefore should be avoided.
- nh23423fefe 4y agoWhat makes a case complex?
- Koshkin 4y agoAn indirect recursion.
- IIAOPSW 4y agoRecursion is just spiral reasoning. It looks like circular reasoning, but if you keep going with it the curve keeps getting smaller until eventually you reach the trivial case.
- kian 4y agoHonestly, this is the best single-line definition for a non-specialist I have ever seen.
- IIAOPSW 4y agoHow many single line definitions for non-specialists have you seen?
- kian 4y agoI have myself tried to explain recursion many times to those who do not understand it. While I do well, this is significantly more succinct than what it would take for me to succeed with most, and provides a clear visual. Nicely done. I’ll probably be stealing that metaphor.
- IIAOPSW 4y agoPlease, credit it to Euler.
- stev-0 4y agoI don’t think recursion is that hard to reason about. You need an understanding of how to work with it. This requires practice in the same way dealing with trigonometry required that. If you are a programmer and feel that dealing with recursion is hard I think you’ve got an opportunity for growth there. It’s true that recursion is harder to deal with than loops. I generally use loops and recursion for a different class of problems. Working with trees of arbitrary depth is much easier when using recursion.
- schwartzworld 4y agoUnless you are working in a functional language and don't have loops.