Intersecting number wheels: Difference between revisions
Content added Content deleted
m (→Python: Functional composition: Updated primitives, tidied.) |
|||
Line 1,780:
<lang python>'''Intersecting number wheels'''
from functools import reduce▼
from itertools import cycle, islice
▲from functools import reduce
Line 1,796:
insertDict(wheelName)(leftRotate(wheel))(wheels)
)(v)
return
return click(wheelMap)('A')
Line 1,808:
#
# main :: IO ()
def main():
Line 1,832:
#
# Tuple (,) :: a -> b -> (a, b)
Line 1,860:
# insertDict :: String -> a -> Dict -> Dict
def insertDict(k):
'''A new dictionary updated with a (k, v) pair.'''
def go(v, dct):
return dup▼
return lambda v: lambda dct: go(v, dct)
Line 1,870 ⟶ 1,868:
# mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])
def mapAccumL(f):
'''A tuple of an accumulation and a
with accumulation from left to right.
'''
def
tpl = f(a[0])(x)
return
def
def g(xs):
return reduce(nxt, xs, (acc, []))
return go
|