Lisp提供一项称作尾部递归优化的性能优化技术。
Lisp offers a performance optimization called tail recursion optimization.
最新版本的GCC也包含了一些在受限环境下的尾部递归优化。
Recent versions of GCC also include some tail-recursion optimizations under limited circumstances.
由于尾部递归优化,这种方式是对列表进行迭代的一种非常简单的方式。
With tail-recursion optimization, this idiom is a marvelously concise way to iterate over a list.
如果我们能找到一个除去这些不需要的栈结构的方法,那么我们的尾部递归函数就可以在固定大小的栈中运行。
If we could find a way to remove these unneeded stack frames, our tail-recursive functions would run in a constant stack size.
在处理递归时,Haskell有两大优势:Haskell优化了尾部递归,Haskell是惰性的。
Haskell has two primary advantages when dealing with recursion: Haskell optimizes tail recursion, and Haskell is lazy.
first能够去除列表的第一个元素,rest简化了将尾部递归(清单9中的递归类型)应用于列表其余部分的过程。
First can peel off the first element of the list, and rest makes it easy to apply tail recursion — the type of recursion in Listing 9 — to the rest.
first能够去除列表的第一个元素,rest简化了将尾部递归(清单9中的递归类型)应用于列表其余部分的过程。
First can peel off the first element of the list, and rest makes it easy to apply tail recursion — the type of recursion in Listing 9 — to the rest.
应用推荐