Binary digits: Difference between revisions
Content added Content deleted
(→Custom functions: Updated output to conform with task description tests.) |
m (→Python :: Custom functions: Used divmod in lieu of two operators in boolsFromInt) |
||
Line 3,075:
decomposition of an integer.'''
def go(x):
return Just((q, bool(r))) if x else Nothing()
return unfoldl(go)(n)
Line 3,134 ⟶ 3,135:
'''Integer enumeration from m to n.'''
return lambda n: list(range(m, 1 + n))
# fmapTuple (<$>) :: (a -> b) -> (a, a) -> (a, b)
def fmapTuple(f):
'''A pair in which f has been applied to
the second item.'''
return lambda tpl: (tpl[0], f(tpl[1]))
|