def bond_neighbors_except_go

bend-prot@0.1.0.0 · bonded.bend:344

import bend-prot@0.1.0.0/bonded.bend as Bonded
import Base

344# Angle auto-derivation from flat bonds: for each bond, fan over the other
345# neighbors of each end. Needs no templates; duplicates across overlapping
346# fans are possible in rings (documented, harmless for boolean use).
347def bond_neighbors_except_go(bs: List<&2, U32>, +s: U32, +excl: U32, +acc: List<&2, U32>) -> List<&2, U32>:
348  match bs:
349    case Nil{}:
350      List.reverse(&2, U32, acc)
351    case x <> Nil{}:
352      List.reverse(&2, U32, acc)
353    case x <> y <> t:
354      +x2 = x
355      +y2 = y
356      bond_neighbors_except_go(t, s, excl, Bool.pick(List<&2, U32>, U32.is_eq(x2, s), Bool.pick(List<&2, U32>, U32.is_eq(y2, excl), acc, y2 <> acc), Bool.pick(List<&2, U32>, U32.is_eq(y2, s), Bool.pick(List<&2, U32>, U32.is_eq(x2, excl), acc, x2 <> acc), acc)))

Uses (5)

Used by (1)