def nth0
import bend-collections-laws-math@1.0.0.0/spec/math/natural.bend as Naturalimport Base
98# xs[i], or dflt past the end
99def nth0(+xs: List<&2, Nat>, +i: Nat, +dflt: Nat) -> Nat:
100 match xs i:
101 case Nil{} i0:
102 dflt
103 case Con{x, t} 0n:
104 x
105 case Con{x, t} 1n+j:
106 nth0(t, j, dflt)