码迷,mamicode.com
首页 > 其他好文 > 详细

Recursion

时间:2014-05-01 18:40:44      阅读:302      评论:0      收藏:0      [点我收藏+]

标签:style   blog   width   2014   cti   http   com   for   amp   os   images   

Recursion

It is legal for one function to call another; it is also legal for a function to call itself. It may not be obvious why what is a good thing, but it turns out to be one of the most magical things a program can do. For example:

 bubuko.com,布布扣                      

If a recursion never reaches a base case, it goes on making recursive calls forever, and the program never terminates. This is known as infinite recursion, and it is generally not a good idea. In most programming environments, a program with infinite recursion does not really run forever. Python reports an error message when the maximum recursion depth is reached:

 bubuko.com,布布扣

When the error occurs, there are 1000 recurse frames on the stack.

 

form Thinking in Python

 

Recursion,布布扣,bubuko.com

Recursion

标签:style   blog   width   2014   cti   http   com   for   amp   os   images   

原文地址:http://www.cnblogs.com/ryansunyu/p/3702828.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!