将一个常见的循环转化为递归函数。
您已经在Lisp中实现了递归函数。
可见,递归函数与循环有很多类似之处。
As you can see, recursive functions and loops have quite a bit in common.
这将允许匿名递归函数。
此外,递归函数也增强了语言的表达能力。
In addition, recursive functions add significant expressive power to the language.
让我们来看一些基于链表的递归函数示例。
Let's look at a few examples of recursive functions on linked lists.
得到的样式表有太多递归函数,难以调试。
The resulting stylesheets have many recursive functions and are difficult to debug.
但是只用递归函数来遍历树并不十分困难。
But walking a tree just by using recursive functions is not all that difficult.
接下来,创建递归函数。
否则,使用递归函数计算阶乘。
Otherwise, a recursive function is used to calculate the factorial.
使递归函数不能得到正确的结果。
答案是递归函数。
我怎么能连续的递归函数?
实际上,可以认为循环和递归函数是能够相互转换的。
In fact, loops and recursive functions can be considered interchangeable.
我们的下一个基于列表的递归函数示例要稍微复杂一些。
Our next example of a recursive function on lists will be a little more complicated.
您可以开发递归函数来处理项、项中的对象、作者等等。
You can develop recursive functions to handle entries, objects within entries, authors, and so on.
了解为什么需要堆栈的最好方法是查看递归函数的情况。
The best way to see why stacks are needed is to look at recursive functions. For simplicity, let's look at the recursive implementation of the factorial function.
此外,递归函数还会遇到浏览器调用栈大小的限制。
Further, recursive functions are more likely to run into browser call stack size limits.
不过,对于递归函数的使用,人们所关心的一个问题是栈空间的增长。
However, one concern people have with the use of recursive functions is the growth of stack space.
这就是递归函数是如何保证其他活动函数调用中的变量值不受影响的。
This is how recursive functions keep from trashing the values of the variables in other, active function calls.
这对于所有的函数来说都是这样,而不仅仅是递归函数如此。
可能理解它的最佳途径是接触一个实际的例子,我们需要一个递归函数。
Probably the best way to understand is with a real example and to do that, we need a recursive function.
当我们将循环转化为递归函数时,递归调用是函数所做的最后一件事情。
When we converted our loop to a recursive function, the recursive call was the last thing that the function did.
在表1中了解循环的特性,看它们可以如何与递归函数的特性相对比。
Take a look at the properties of loops and see how they compare with those of recursive functions in Table 1.
让我们来研究一个打印报表的常见循环,了解如何将它转化为一个递归函数。
Let's take a look at a common loop for printing reports and see how it can convert into a recursive function.
之所以需要这么做是因为参数会在递归函数调用上被截断,而以后却还需要访问它。
You need to do this because your parameter will get clobbered on the recursive function call, and you will need access to it afterwards.
我想它可作为一个很好的MSSAX,递归函数和子程序等等的示例。
I thought it might be good as an example of MS SAX, recursive functions and subroutines and more.
编写这种递归函数需要执行的步骤如下所示,清单3给出了这个函数的源代码。
The steps required to write such a recursive function are listed below, and Listing 3 presents the source code of the function itself.
递归函数有时对资源的消耗量很大,而且在用户失去耐心之前可能还没有返回结果。
Recursive functions can sometimes be very resource hungry and may not return results before a user loses patience.
在编写递归函数时,命名let能够相当程度地减少键盘输入以及出现错误的数量。
The named let cuts down considerably on the amount of typing and mistakes made when writing recursive functions.
应用推荐