[erlang-questions] Modeling Recursion into Tail Recursion

Eric Skoglund eric@REDACTED
Sat Mar 14 17:55:16 CET 2015

On Sat, Mar 14, 2015 at 07:57:22AM -0700, Harit Himanshu wrote:
> *Question*
>    1. Since the concept for tail recursion is new to me I specially wanted
>    to ask that how could I model my thinking to turn recursive functions into
>    tail-recursive functions?
>    2. Can we turn every recursive function into tail-recursive? If no, how
>    to identify?

One resource that helped me a lot was the recursion chapter of learn you
some erlang: http://learnyousomeerlang.com/recursion#hello-recursion

As for the second question I'm not 100% sure I'm remembering this
correctly but using continuation-passing-style you could express every
recursive function with tail-recursion. 

// Eric Skoglund

More information about the erlang-questions mailing list