This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/algo/legacy/order

The comparisons of the legacy copies (lib/algo/legacy/*.viv), each a def so that the interpreter's call graph counts it (tools/algo/check.py reads the counts from the __graph__ line), and so that McIlroy's adversary can stand in for them.

With LG_MODE[0] == 0 each def is the operator it is named for, so a legacy copy computes exactly what the corpus code it was copied from computes. With LG_MODE[0] == 1 the values compared are item ids 0 .. n-1, and the result comes from McIlroy's adversary (M. D. McIlroy, "A killer adversary for quicksort", Software: Practice and Experience 29(4), 1999): every item starts as "gas", worth more than any frozen item; a comparison of two gas items freezes one of them at the next smallest value, choosing the item that was compared last (the likely pivot). The values frozen during one sort are an input on which that sort makes the comparisons it made under the adversary.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 16–119