def ends
import lawful-fields@0.1.1.0/defs.bend as Defsimport Base
170# The end offset of each piece, the first piece starting at from and each next
171# one just after the previous end.
172def ends(ps: List<&2, List<&2, U32>>, +from: Nat) -> List<&2, Nat>:
173 match ps:
174 case Nil{}:
175 Nil{}
176 case Con{p, t}:
177 +e = Nat.add(from, List.length(&2, U32, p))
178 Con{e, ends(t, Nat.add(e, 1n))}