Survival.insert_row.go: def of unified-nsga-iii@0.2.2.0 Import: import unified-nsga-iii@0.2.2.0/survival.bend as Survival Lines 1032-1054 of unified-nsga-iii@0.2.2.0/survival.bend: https://jend.leeeet.dev/read.txt?path=unified-nsga-iii@0.2.2.0/survival.bend&start_line=1032&end_line=1054 import Base # Insertion sort step. One def: the recursive call is only the # `before = False` arm, and that arm's tail is the original rest. # `before = True` conses onto that same rest (no second insert). # phase 0 reads the next cons; phase 1 places the row. Fuel is 1+2|xs|. # Recursing through a tail that already contains `x`, then consing `x` # again, duplicates the row. Each smaller CV doubles the list. At the # constrained budgets that exponential spine overflows the native stack # (`memory fault (machine stack overflow?)` on OSY / C1-DTLZ1; TNK # fail-stops). `src/constrained_budget.bend` runs those budgets. def insert_row.go(fuel: Nat, phase: Nat, before: Bool, +x: CvRow, xs: List<&2, CvRow>, +h: CvRow) -> List<&2, CvRow>: match fuel phase before: case 0n p b: x <> xs case 1n+f 0n b: match xs: case Nil{}: x <> Nil{} case +head <> tail: insert_row.go(f, 1n, row_before(x, head), x, tail, head) case 1n+f 1n+ph True{}: x <> h <> xs case 1n+f 1n+ph False{}: h <> insert_row.go(f, 0n, False{}, x, xs, h) Uses (5): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/survival.bend&name=CvRow https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/survival.bend&name=row_before