Loops/Increment loop index within loop body: Difference between revisions

m
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):
'''IntegerSecond stringinteger shown with comma-chunked digits.'''
return '{:2} -> {:20,}'.format(*tpl)
 
 
Line 3,336 ⟶ 3,344:
yield v
v = f(v)
return lambda x: go(x)
 
 
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)
 
 
9,659

edits