def alignment_runs_reversed

bend-edit-distance@0.2.2.0 · EdlibTypes.bend:140

import bend-edit-distance@0.2.2.0/EdlibTypes.bend as EdlibTypes
import Base

140# The current run depends on the preceding symbol, so this scan is sequential.
141# Tail recursion keeps long homogeneous and alternating paths bounded in stack.
142def alignment_runs_reversed(operations: List<&2, Operation>, +format: CigarFormat,
143                             runs: List<&2, CigarRun>) -> List<&2, CigarRun>:
144  match operations runs:
145    case Nil{} _:
146      runs
147    case h <> t Nil{}:
148      alignment_runs_reversed(t, format, [CigarRun{1n, operation_char(format, h)}])
149    case h <> t CigarRun{count, +symbol} <> tail:
150      +next = operation_char(format, h)
151      alignment_runs_reversed(t, format,
152        cigar_run_step(tail, count, symbol, next, Char.is_eq(symbol, next)))

Uses (7)

Used by (1)