Tail Recursion vs Forward recursion in Erlang -


is tail recursion better forward recursion perfomance in erlang?
or erlang compiler optimizes forward recursion too?
mean, there reasons use tail recursion instead of forward recursion?
in opinion, forward recursion looks more pretty.

tail recursion better because uses less memory. bring need onto next call, minimizes memory utilization on stack. also, when tail recursive code optimized, function returns not needed thrown away make faster in cases.

for example, if function's return value call function, there no need keep intermediary function on stack. code jumps directly caller inner function.

non-tail recursion optimized tail recursion in cases erlang compiler, don't count on it. make habit code tail recursive functions whenever can.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -