Kay Schluehr wrote:


Since it is acting on a tree why doesn't the code substitute self in
its parent by SS? That's the natural perspective if one considers a
tree as a linked structure and inserts and deletes nodes within this
structure.

I think you are suggesting the same thing I did:

> If you examine nodes from their parent, I believe you can do the
> > substitution in one step. Something like:
> >
> > for slot,child in ( ('left',self.left), ('right',self.right) ):
> >   if child is not None:
> >     if child.val == 'f':
> >       setattr(self, slot, F.copy().subst('x', child.left))
> >     child.elimF
> >
> > where .subst returns the modified tree.

Where F.copy is what was called 'SS'.  If not, I don't understand.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to