Return running totals
(iterable, func=operator.add)
| 12 | #mpl.rcParams['font.sans-serif'] = ['Microsoft YaHei'] #ָ��Ĭ������ |
| 13 | |
| 14 | def accumulate(iterable, func=operator.add): |
| 15 | 'Return running totals' |
| 16 | # accumulate([1,2,3,4,5]) --> 1 3 6 10 15 |
| 17 | # accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120 |
| 18 | it = iter(iterable) |
| 19 | total = next(it) |
| 20 | #rst = [] |
| 21 | yield total |
| 22 | for element in it: |
| 23 | total = func(total, element) |
| 24 | yield total |
| 25 | |
| 26 | font = FontProperties(size=8) |
| 27 | font_big = FontProperties(size=14) |
no test coverage detected