Cli.osa_row: def of cli@0.2.0.0 Import: import cli@0.2.0.0/cli.bend as Cli Lines 5692-5706 of cli@0.2.0.0/cli.bend: https://jend.leeeet.dev/read.txt?path=cli@0.2.0.0/cli.bend&start_line=5692&end_line=5706 import Base # Row i of optimal string alignment for a[i]: up starts at d[i-1][j-1], up2 # at d[i-2][j-2], and left is d[i][j-1]. def osa_row(bs: String, bp: Maybe<&2, Char>, +a: Char, +ap: Maybe<&2, Char>, +up: List<&2, Nat>, +up2: List<&2, Nat>, left: Nat) -> List<&2, Nat>: match bs: case SNil{}: Nil{} case SCon{+b, tail}: +diag = head_nat(up) +rest = tail_nats(up) +edit = Nat.min(Nat.min((head_nat(rest) + 1n : Nat), (left + 1n : Nat)), Bool.pick(Nat, Char.is_eq(a, b), diag, (diag + 1n : Nat))) +best = Bool.pick(Nat, Bool.and(same_char(bp, a), same_char(ap, b)), Nat.min(edit, (head_nat(up2) + 1n : Nat)), edit) best <> osa_row(tail, Some{b}, a, ap, rest, tail_nats(up2), best) Uses (13): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Char https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Char.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe 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.min https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=head_nat https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=same_char https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=tail_nats