25

"people stare at recursive programs for a long time without understanding how they work. Then, one day, they suddenly get it—and they don't understand why they ever thought it was difficult.

Evidently, the key to understanding recursion is to begin by understanding recursion. The rest is easy."

- Andrew Koening & Barbara E Moo

Found this gem while going through Accelerated C++

Comments
  • 1
    Just google recursion.
  • 2
    Btw I remember the moment quite well when I first encountered recursion in some code and was completely mind blown.
    "Wtf, why does the function call itself and why does it even work?"
    Fun times 😅
  • 1
    Recursion is the lazy way if creating for-for-for-... loops without needing multiple counters.

    I used to do the latter all the time... Now I just look at a problem to make sure the use case won't lead to stack overflow.

    I feel both dumber and smarter now....
  • 0
    @billgates just use tail recursion. A trick which will prevent stack overflows :)
  • 0
    @Lensflare that's language specific? I only one I remember was Scala but haven't touched that in years
  • 0
    @billgates it should in theory be not language dependent. I know it from c++
    I mean proper languages. Not some horse shit like JS. :)
Add Comment