Recursive algorithms anyone?
Greg Jorgensen
gregj at pobox.com
Thu Jun 7 03:53:50 EDT 2001
How about this. Ignore the "lists" list to get the "other" behavior.
from __future__ import nested_scopes
def additem(items, k):
from types import ListType
def _additem(items, k):
if id(items) not in lists:
lists.append(id(items))
i = 0
for x in items:
if type(x) is ListType:
_additem(x, k)
else:
items[i] = x + k
i += 1
lists = []
_additem(items, k)
--
Greg Jorgensen
PDXperts LLC
Portland, Oregon, USA
gregj at pobox.com
More information about the Python-list
mailing list