Loops/Increment loop index within loop body: Difference between revisions
Loops/Increment loop index within loop body (view source)
Revision as of 17:28, 30 March 2020
, 4 years ago→Functional Python
m (→Functional Python: Updated output.) |
|||
Line 3,259:
def go(tpl):
if isPrime(tpl[1]):
# Side effect.
print(showTuple(tpl))
# Value.
return splitArrow(succ)(dbl)(tpl)
else:
Line 3,285 ⟶ 3,287:
return not any(map(p, range(5, 1 + int(n ** 0.5), 6)))
# showTuple :: (Int, Int) -> String▼
def showTuple(tpl):▼
return '{:2} -> {:20,}'.format(*tpl)▼
Line 3,336 ⟶ 3,344:
yield v
v = f(v)
return
Line 3,345 ⟶ 3,353:
'''
return lambda tpl: (tpl[0], f(tpl[1]))
▲# showTuple :: (Int, Int) -> String
▲def showTuple(tpl):
▲ '''Integer string with comma-chunked digits.'''
▲ return '{:2} -> {:20,}'.format(*tpl)
|