best cumulative sum

Paul Rubin http
Tue Nov 22 15:06:12 EST 2005


Here's a silly recursive version (don't really use, it's too slow):

def csum(s):
        if len(s)==0: return s
        return csum(s[:-1]) + [sum(s)]



More information about the Python-list mailing list