Tail Recursion in Scala

scala

Recursion v/s Loops in Scala

Reading Time: 3 minutes Loops need mutation, As it keeps changing the value of the variable, Scala hates mutation. Why? What is Mutation? A mutation is changing an object, variable and is one of the common side effects. Now the question arises why does scala hate mutation? Mutation might result in ambiguity, unanticipated errors, and a difficult time debugging the problem. Mutation makes it more difficult to decipher code. Continue Reading

Recursion and Tail Recursion in Scala

Reading Time: 4 minutes Introduction: Recursion is quite common in the programming world. If you don’t know recursion, it means, solving a problem by breaking it into smaller sub-problems until you solve it trivially. You can easily spot recursion if you see a method calling itself with a smaller subset of input. Recursion and immutability are corner zone of functional programming. As we have seen earlier, while using loops, Continue Reading

Recursion in scala in a simple way

Reading Time: 4 minutes What is Recursion? It is the technique of making a function call itself directly or indirectly and the corresponding function is called a recursive function. This technique provides a way to break complicated problems down into simple problems which are easier to solve. Recursion may be a bit difficult to understand and it can take some time to get your head around how it works Continue Reading