Mian-Chowla sequence: Difference between revisions
m
→Functional Python: (uncurried nextMC)
(→Python: Simplified compositional subheader to functional) |
m (→Functional Python: (uncurried nextMC)) |
||
Line 1,172:
===Functional===
{{Works with|Python|3.7}}
<lang python>
from itertools import (islice)
Line 1,187:
while True:
yield x
(sumSet, x) = nextMC(sumSet
mcs.append(x)
# nextMC :: Set Int -> [Int] -> Int -> (Set Int, Int)
def nextMC(setSums, mcs, n):
'''Set of sums -> series so far ->
current term -> (updated set of sums, next term)
'''
def
|