Myers.trim_semiglobal: def of bend-edit-distance@0.2.2.0 Import: import bend-edit-distance@0.2.2.0/src/Myers.bend as Myers Lines 465-480 of bend-edit-distance@0.2.2.0/src/Myers.bend: https://jend.leeeet.dev/read.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&start_line=465&end_line=480 import Base import bend-edit-distance@0.2.2.0/EdlibTypes.bend as E # If the bottom score is >= k+32 every cell in that block is > k. Only # trailing blocks are removed. HW always retains block zero: its free top # boundary can seed a new alignment after an arbitrarily long target prefix. def trim_semiglobal(entries: List<&2, BandEntry>, rest: List<&2, Peq>, +mode: E.Mode, +index: Nat, +maximum: Nat) -> List<&2, BandEntry> & List<&2, Peq>: match entries mode: case Nil{} _: (Nil{}, rest) case BandEntry{profile, Block{pv, mv, +score}} <> tail E.HW{}: trim_last.join(BandEntry{profile, Block{pv, mv, score}}, trim_semiglobal(tail, rest, mode, 1n+index, maximum), Bool.or(Nat.is_eq(index, 0n), Nat.is_lt(U32.to_nat(score), Nat.add(maximum, 32n)))) case BandEntry{profile, Block{pv, mv, +score}} <> tail _: trim_last.join(BandEntry{profile, Block{pv, mv, score}}, trim_semiglobal(tail, rest, mode, 1n+index, maximum), Nat.is_lt(U32.to_nat(score), Nat.add(maximum, 32n))) Uses (14): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or 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=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/EdlibTypes.bend&name=Mode https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&name=BandEntry https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&name=Block https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&name=Peq https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Myers.bend&name=trim_last.join