Pdb.group_chain_go: def of bend-prot@0.1.0.0 Import: import bend-prot@0.1.0.0/pdb.bend as Pdb Lines 409-417 of bend-prot@0.1.0.0/pdb.bend: https://jend.leeeet.dev/read.txt?path=bend-prot@0.1.0.0/pdb.bend&start_line=409&end_line=417 import Base import bend-prot@0.1.0.0/protein.bend as P # Pass 2: consecutive equal chains merge into Chain. def group_chain_go(items: List<&1, U32 & P.Residue>, +cur_c: U32, +cur_rs: List<&2, P.Residue>, +acc: List<&2, P.Chain>) -> List<&2, P.Chain>: match items: case Nil{}: List.reverse(&2, P.Chain, P.Chain{cur_c, List.reverse(&2, P.Residue, cur_rs)} <> acc) case (c, r) <> t: +c2 = c +same = U32.is_eq(c2, cur_c) group_chain_go(t, Bool.pick(U32, same, cur_c, c2), r <> Bool.pick(List<&2, P.Residue>, same, cur_rs, Nil{}), Bool.pick(List<&2, P.Chain>, same, acc, P.Chain{cur_c, List.reverse(&2, P.Residue, cur_rs)} <> acc)) Uses (9): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.reverse 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 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=bend-prot@0.1.0.0/protein.bend&name=Chain https://jend.leeeet.dev/definition.txt?path=bend-prot@0.1.0.0/protein.bend&name=Residue