In the first announcement of functional programming, many functional languages didn't have the loop feature to iterate the sequence. All we had to do was construct the recursion process to iterate the sequence. Although C# has iteration features such as for
and while
, it is better if we discuss recursion in the functional approach. Recursion will also simplify our code. To do that, in this chapter, we will discuss the following topics:
Understanding how the recursive routine works
Refactoring an iteration into a recursion
Distinguishing tail recursion between the accumulator-passing style and the continuation-passing style
Understanding indirect recursion over direct recursion
Applying recursion in the functional approach using the Aggregate LINQ operator