Tail/Non tail recursion

Vlad Dumitrescu <>
Thu Aug 28 15:39:34 CEST 2003


Hi,

----- Original Message ----- 
From: "Luke Gorrie" <>
> > square([H|T]) -> [H*H|square(T)];
> > square([]) -> [].
>
> Short answer: That's best in that it uses time and space proportional
> to the length of the list, just like lists:map, list comprehension,
> etc.

Did I miss the fact that the Erlang compiler now also does cons-tail-call
optimizations? (or whatever it is called :-)
I remember that was not the case for some versions ago, and I did not look at
all the change logs... or I just forgot about it...

regards,
Vlad



More information about the erlang-questions mailing list