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...
a = [1, 2, 3 ,4, 5] # Using list comprehention cumsum = [sum(a[:i+1]) for i in range(len(a))] # [1, 3, 6, 10, 15] # Using map() cumsum = map(lambda i: sum(a[:i+1]), range(len(a))) # [1, 3, 6, 10, 15]