def nth0

bend-collections-laws-math@1.0.0.0 · spec/math/natural.bend:98

import bend-collections-laws-math@1.0.0.0/spec/math/natural.bend as Natural
import 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)

Uses (2)

Used by (3)