Using functional tools

Patrick W quitelikely at yahoo.com.au
Sat May 4 09:35:09 EDT 2002


Patrick W <quitelikely at yahoo.com.au> writes:

[...]

Or, if the OP's religion forbids 'fors' or 'whiles' under any
circumstances:

def do_every_nth(seq, func, n):
    def transform(item, index):
        if index % n == n - 1: return func(item)
        else: return item
    return map(transform, seq, range(len(seq)))



More information about the Python-list mailing list