James Stroud <[EMAIL PROTECTED]> writes: > def f(n): > if n>0: > yield n%26 > for i in f(n/26): > yield i
Right, this mutates i though. Let's say we have a library function itertools.iterate() and that we ignore (as we do with functions like "map") that it uses mutation under the clothes: def iterate(f, x): # generate the infinite sequence x, f(x), f(f(x)), ... while True: yield x x = f(x) Then we could write: from itertools import imap, takewhile def snd((a,b)): return b def f(n): return takewhile(bool, imap(snd, iterate(lambda (a,b): divmod(a,26), divmod(n,26)))) -- http://mail.python.org/mailman/listinfo/python-list