A function is called tail recursive when the recursive call to itself happens only in the last expression of the body in every clause.
1 2 3 4 5 6 7 8
The first function is not the tail recursive as the recursive call is followed by other expression. While the second is, since the recursive call is the last statement.
Tail Recursion & Performance
In many programming languages tails recursion is a good approach performance. But in general, it is not the case in the latest releases of Erlang. Tail recursion is not guaranteed to give you better performance.
Tail Recursion VS Non Tail Recursion
Non Tail Recursive:
1 2 3 4