Loops/Increment loop index within loop body: Difference between revisions
Content deleted Content added
m →Functional Python: Updated output. |
|||
Line 3,259: | Line 3,259: | ||
def go(tpl): |
def go(tpl): |
||
if isPrime(tpl[1]): |
if isPrime(tpl[1]): |
||
# Side effect. |
|||
print(showTuple(tpl)) |
print(showTuple(tpl)) |
||
# Value. |
|||
return splitArrow(succ)(dbl)(tpl) |
return splitArrow(succ)(dbl)(tpl) |
||
else: |
else: |
||
Line 3,285: | Line 3,287: | ||
return not any(map(p, range(5, 1 + int(n ** 0.5), 6))) |
return not any(map(p, range(5, 1 + int(n ** 0.5), 6))) |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
Line 3,336: | Line 3,344: | ||
yield v |
yield v |
||
v = f(v) |
v = f(v) |
||
return |
return go |
||
Line 3,345: | Line 3,353: | ||
''' |
''' |
||
return lambda tpl: (tpl[0], f(tpl[1])) |
return lambda tpl: (tpl[0], f(tpl[1])) |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||