Skip to content

docs(conferences): correct the short-circuit claim in the sorting chapter - #348

Merged
apiad merged 1 commit into
mainfrom
docs/libro-cortocircuito
Nov 4, 2026
Merged

apiad merged 1 commit into
mainfrom
docs/libro-cortocircuito

Conversation

@apiad

@apiad apiad commented Nov 4, 2026

Copy link
Copy Markdown
Member

The sorting chapter said that swapping j >= 0 and lista[j] > x in the insertion sort would make the program wrong. In Python it does not: lista[-1] is a valid index, and j >= 0 stops the loop right after. The swapped version sorts all 21 845 lists over {1..4} up to length 7.

The paragraph now says that, and shows a loop where the order does matter: while i < len(lista) and lista[i] != x raises IndexError with the conditions swapped.

Prose only. The rebuilt programacion.pdf (scriptorium 0.13.0) leaves .scriptorium/freeze.json byte-identical, keeps 21 tracebacks and 33 figures, and grows from 155 to 156 pages.

…pter

The chapter said that swapping the two conditions of the insertion
sort's while loop would break it. It does not: lista[-1] exists, and
j >= 0 still stops the loop right after. The paragraph now says so and
shows a loop where the order does matter, a search that raises
IndexError with the conditions swapped. Prose only, so no block reran.
@apiad
apiad merged commit f364bf3 into main Nov 4, 2026
2 of 3 checks passed
@apiad
apiad deleted the docs/libro-cortocircuito branch November 4, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant