Recursion Explained In Simple Terms

--

Most tutorials explain recursion using factorials or Fibonacci sequences. That’s nice for learning, but you won’t use those in real work. Let’s look at recursion through actual code you might write.

Think of recursion like reading through a thread of Slack comments. You see a message with replies, and those replies have their own replies, and it keeps going deeper. Each level of replies is the same thing — just messages and responses — but each level is dealing with a smaller piece of the conversation.

In programming, recursion works the same way. A function calls itself to handle a smaller version of the same task. Here’s a Slack comment system to see how recursion works.

Continue reading

--

--

No responses yet