Linux 拨号vps windows公众号手机端

python怎么强制结束递归函数

lewis 6年前 (2019-04-04) 阅读数 9 #程序编程
文章标签 python递归函数

在python中强制结束递归函数的方法以下两种

1.使用return语句结束

def count(dict, key, depth):

if key is not None:

if key == 42:

return depth

return count(map, map[key][0], depth+1)

return count(map, map[key][1], depth+1)

2.通过在递归函数外定义一个isGo全局变量结束

var isGo:Boolean=true

functionarr_all(pre:Array,nex:Array) {

if(isGo==false){return}

var j:uint=nex.length;

if (j==1) {

var t=[];

for (var i:uint=0;i

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门