Recursive algorithms anyone?

Alan Green web.mail at lycos.com
Tue Jun 12 16:30:50 EDT 2001


"Nick Perkins" <nperkins7 at home.com> wrote in message news:<D4qV6.204460
... snip ...
> 
> def additem(x):
>     if type(x) is type([]): return map(additem,x)
>     else: return x+1

I have to have a go at this too! Combining Nick's with Piet's...

def add(x, k):
    if type(x) == type([]):
            return [add(l, k) for l in x]
    return x+k



More information about the Python-list mailing list