Range consolidation: Difference between revisions
→Functional Python: Added a couple of comments to the `consolidated` function.
(→{{header|Python}}: Added a 'Procedural' peer to the 'Functional' heading) |
(→Functional Python: Added a couple of comments to the `consolidated` function.) |
||
Line 480:
def go(abetc, xy):
'''A copy of the accumulator abetc,
with its head range ab either:
2. merged with
the next range xy, or
with xy simply prepended.'''
if abetc:
a, b = abetc[0]
▲ x, y = xy
etc = abetc[1:]
[(x, b)] + etc if y >= a else ( #
[xy] + abetc # xy simply prepended.
)
)
|