What would be an elegant and pythonic way to implement cumsum? Alternatively - if there\'a already a built-in way to do it, that would be even better of course...
for loops are pythonic
def cumsum(vec): r = [vec[0]] for val in vec[1:]: r.append(r[-1] + val) return r