Skip to content

Commit 52b9e01

Browse files
committed
Added comsum and comprod, not tested yet
1 parent 91a6770 commit 52b9e01

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

MiniPy.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@
99
import sublime_plugin
1010

1111

12+
def cumsum(lst):
13+
return [sum(lst[:i]) for i in range(len(lst))]
14+
15+
16+
def cumprod(lst, use_logsum=False):
17+
def do_cumprod(lst):
18+
tmp = 1
19+
toReturn = list()
20+
for el in lst:
21+
tmo *= el
22+
toReturn.append[tmp]
23+
return toReturn
24+
25+
if use_logsum:
26+
return [exp(el_log) for el_log in do_cumprod((log(el) for el in lst))]
27+
else:
28+
return do_cumprod(lst)
29+
30+
1231
def dnow():
1332
return datetime.datetime.strftime(datetime.datetime.now(), '%d/%m/%Y')
1433

0 commit comments

Comments
 (0)