15 lines
500 B
Text
15 lines
500 B
Text
--| Retrieve an element from a `List` using its 0-based index
|
|
let drop = ./drop.dhall
|
|
|
|
let index
|
|
: Natural → ∀(a : Type) → List a → Optional a
|
|
= λ(n : Natural) → λ(a : Type) → λ(xs : List a) → List/head a (drop n a xs)
|
|
|
|
let property =
|
|
λ(n : Natural) → λ(a : Type) → assert : index n a ([] : List a) ≡ None a
|
|
|
|
let example0 = assert : index 1 Natural [ 2, 3, 5 ] ≡ Some 3
|
|
|
|
let example1 = assert : index 1 Natural ([] : List Natural) ≡ None Natural
|
|
|
|
in index
|