def pairs
import bendtorch@1.3.0.0/dtype.bend as Dtypeimport Base
141# the values two by two; an odd last one is paired with 0
142def pairs(xs: List<&2, U32>) -> List<&2, HW>:
143 match xs:
144 case Nil{}:
145 Nil{}
146 case Con{a, Nil{}}:
147 [HW{a, 0}]
148 case Con{a, Con{b, t}}:
149 HW{a, b} <> pairs(t)