I want to get a running total from a list of numbers.
For demo purposes, I start with a sequential list of numbers using range
range
a = range
This can be implemented in 2 lines in Python.
Using a default parameter eliminates the need to maintain an aux variable outside, and then we just do a map to the list.
map
def accumulate(x, l=[0]): l[0] += x; return l[0]; map(accumulate, range(20))