Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Gregory Piñero
Ok, I finally got it working! See below On 2/4/06, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 04 Feb 2006 02:18:27 -0500, Gregory Piñero wrote: > > class Node: > > def __init__(self): > > self.arg0=0 > > self.arg1=0 > > self.arg2=0 > > self.arg3=0 > >

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Scott David Daniels
Gregory Piñero wrote: > I want to walk down each tree and get a random subtree at a random > depth. Can you quantify that randomness? Should it be uniform at each level? Thinking about this may be fruitful. I don't yet know whether you need to see all leaves before you know which subtree

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Gregory Piñero
Thanks for the advice guys. See below. On 2/4/06, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 04 Feb 2006 02:18:27 -0500, Gregory Piñero wrote: > > > class Node: > > def __init__(self): > > self.arg0=0 > > self.arg1=0 > > self.arg2=0 > > self.arg3=0 >

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Steven D'Aprano
On Sat, 04 Feb 2006 02:18:27 -0500, Gregory Piñero wrote: > Hi, > > Would anyone be able to tell me why my function below is getting stuck > in infinite recusion? > Maybe I'm just tired and missing something obvious? Your code is quite confusing, especially since there is very little documentati

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Terry Reedy
>Would anyone be able to tell me why my function below is getting stuck >in infinite recusion? >def replace_within_node(node,oldnode,newnode): >if node is oldnode: >return newnode Without looking further, the most likely reason is that the base case is never true: ie, node is never o

Re: Recursive function going infinite and I can't see why.

2006-02-03 Thread Gregory Piñero
By the way, all I'm trying to do here is take two trees, randomly find a sub-tree of each and swap the sub-trees. So if anyone has a simple method for doing that I'm certainly open to that too. Thanks again, -Greg On 2/4/06, Gregory Piñero <[EMAIL PROTECTED]> wrote: > Hi, > > Would anyone be a

Recursive function going infinite and I can't see why.

2006-02-03 Thread Gregory Piñero
Hi, Would anyone be able to tell me why my function below is getting stuck in infinite recusion? Maybe I'm just tired and missing something obvious? def replace_within_node(node,oldnode,newnode): if node is oldnode: return newnode else: for varname,value in node.__dict__.i