def nth

bend-collections-laws-math@1.0.0.0 · spec/lib/common.bend:70

import bend-collections-laws-math@1.0.0.0/spec/lib/common.bend as Common
import Base

70# Element i, if any.
71def nth(-A: Data, xs: List<&2, A>, i: Nat) -> Maybe<&2, A>:
72  match xs i:
73    case Nil{} _:
74      None{}
75    case Con{h, t} 0n:
76      Some{h}
77    case Con{h, t} 1n+p:
78      nth(A, t, p)

Uses (3)

Used by (9)