1.尾递归是一种很容易改成循环的递归,并不是所有的递归都是尾递归啊。
2.可以看看纯函数式编程的语言,里面没有循环。
3.可以看看有关计算模型,可计算性等方面的资料。
4.针对函数式语言的编译器,对递归的优化是灰常强大的。
5.
引自:http://en.wikipedia.org/wiki/Tail_Recursion
From Wikipedia, the free encyclopedia (Redirected from Tail Recursion)
Jump to: navigation, search
In computer science, a tail call is a subroutine call producing a return value, which is then immediately returned by the calling procedure. The call site is then said to be in tail position, i.e. at the end of the calling procedure. If a subroutine performs a tail call to itself, it is called tail recursive. This is a special case of recursion.
Tail calls are significant because they can be implemented without consuming space on the call stack, because the call can replace the stack frame of the current procedure with the one of the newly called procedure. To do so, it suffices to adjust the subroutine arguments and then jump to the called subroutine. Producing such code instead of a standard call sequence is called tail call elimination (TCE).
Traditionally, tail call elimination is optional, and it can also be called tail call optimization (TCO). However, in functional programming languages, tail call elimination is often guaranteed by the language standard, and this guarantee allows using recursion, in particular tail recursion, in place of loops. In such cases, it is not correct to refer to it as an optimization, even if it is customary practice.