On Jul 14, 2007, at 1:36 AM, Trevor Squires wrote:

> sum([H|T]) -> H + sum(T);
> sum([]) -> 0.
>
> "Oh my god!  Won't that blow the stack?" - well, I *think* it's  
> okay because of something called 'tail-recursion' - but like you, I  
> don't know what I don't know.

For what it's worth: the function definition is "tail-recursive" and  
the technique used by the compiler/interpreter to prevent stack  
overflow is called "tail-recursion elimination". That is, the  
compiler/interpreter transforms the recursion into an iteration  
(which is relatively easy to do for tail-recursive functions).

Regards, Morton