Skip to content

Commit

Permalink
Merge branch 'Maltysen-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacg1 committed Nov 26, 2017
2 parents 015c875 + 36a60b2 commit 5b2363a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,17 @@ def repeat(func, start, repetitions):

# F on binary function. Fold.
def fold(func, lst):
if not lst:
# '*'
if func == environment[c_to_f['*'][0]]:
if func == environment[c_to_f['*'][0]]:
if not lst:
return 1
elif func == environment[c_to_f['+'][0]]:
if not is_col(lst):
return factorial(lst)
if not lst:
if func == environment[c_to_f['+'][0]]:
return []
else:
return 0
else:
return reduce2(func, lst)
return reduce2(func, lst)
environment['fold'] = fold


Expand Down
1 change: 1 addition & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
('*.5,4T', '[2.0, 5.0]'),
('*_5"hi"', ''),
('*"blah"_2', 'halbhalb'),
('*M[1 2 3', '[1, 2, 6]'),
# +
('+4U3', '[4, 0, 1, 2]'),
('+U3U3', '[0, 1, 2, 0, 1, 2]'),
Expand Down

0 comments on commit 5b2363a

Please sign in to comment.