In the last chapter, you learned about immutable states that make us not deal with the side effect. In this chapter, let's take a look at the concept of recursion. As a programmer in object-oriented programming, we usually use iteration to repeat the process instead of recursion. However, recursion gives more benefit than iteration. For instance, some problems (mathematics, especially) are solved easily using recursion, and, fortunately, all algorithms can be defined recursively. That makes it much, much easier to visualize and prove. To get to know more about the recursion, the following topics will be discussed in this chapter:
- Differentiating the iteration and recursion invocation
- Recurring the immutable function
- Finding a better way in recursion using tail recursion
- Enumerating three kinds of recursion--functional...