Comment

Comment by seanhunter

I wish every article that wanted an example of recusion didn't immediately reach for fibbonacci or factorial, both of which are much better expressed by just calculating iteratively from the bottom and then memoizing the results for future calls. When I started to learn programming, for ages I thought recursion was just stupid because every single example I saw in a textbook could better be written without recursion.

For goodness sake if you want to write an example of recursion, walk a tree. That's a great example of a use of recursion given that the iterative version is much clumsier to express.

parent seanhunter 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton