CRC-32: Difference between revisions

Content added Content deleted
Line 1,866: Line 1,866:
(a ^ ord(c)) & 0xff
(a ^ ord(c)) & 0xff
],
],
list(s),
s,
(0xffffffff)
(0xffffffff)
) ^ 0xffffffff
) ^ 0xffffffff
Line 1,883: Line 1,883:




# GENERIC ABSTRACTION -------------------------------------
# ----------------------- GENERIC ------------------------


# index (!!) :: [a] -> Int -> a
# index (!!) :: [a] -> Int -> a
Line 1,897: Line 1,897:
# iterate :: (a -> a) -> a -> Gen [a]
# iterate :: (a -> a) -> a -> Gen [a]
def iterate(f):
def iterate(f):
'''An infinite list of repeated applications of f to x.'''
'''An infinite list of repeated
applications of f to x.
'''
def go(x):
def go(x):
v = x
v = x
Line 1,903: Line 1,905:
yield v
yield v
v = f(v)
v = f(v)
return lambda x: go(x)
return go