def ins
import bend-ml-llama@0.2.1.0/main.bend as BendMlLlamaimport Base
1155# v (id i) into the candidates cs, largest first; g: whether it goes before the head
1156def ins(cs: List<&2, Cand>, g: Bool, +v: F32, +i: Nat) -> List<&2, Cand>:
1157 match cs g:
1158 case Nil{} _:
1159 Cand{v, i} <> Nil{}
1160 case Con{h, t} True{}:
1161 Cand{v, i} <> (h <> t)
1162 case Con{h, +t} False{}:
1163 h <> ins(t, goes_before(t, v), v, i)