getD and getI #
This file provides theorems for working with the getD
and getI
functions. These are used to
access an element of a list by numerical index, with a default value as a fallback when the index
is out of range.
@[deprecated List.getD_eq_get]
theorem
List.getD_eq_nthLe
{α : Type u}
(l : List α)
(d : α)
{n : ℕ}
(hn : n < List.length l)
:
List.getD l n d = List.nthLe l n hn
def
List.decidableGetDNilNe
{α : Type u_1}
(a : α)
:
DecidablePred fun (i : ℕ) => List.getD [] i a ≠ a
An empty list can always be decidably checked for the presence of an element.
Not an instance because it would clash with DecidableEq α
.
Equations
- List.decidableGetDNilNe a x = isFalse ⋯
Instances For
@[simp]
theorem
List.getD_replicate_default_eq
{α : Type u}
(d : α)
(r : ℕ)
(n : ℕ)
:
List.getD (List.replicate r d) n d = d
theorem
List.getD_append_right
{α : Type u}
(l : List α)
(l' : List α)
(d : α)
(n : ℕ)
(h : List.length l ≤ n)
:
theorem
List.getD_eq_getD_get?
{α : Type u}
(l : List α)
(d : α)
(n : ℕ)
:
List.getD l n d = Option.getD (List.get? l n) d
@[deprecated List.getI_eq_get]
theorem
List.getI_eq_nthLe
{α : Type u}
(l : List α)
[Inhabited α]
{n : ℕ}
(hn : n < List.length l)
:
List.getI l n = List.nthLe l n hn
theorem
List.getI_eq_default
{α : Type u}
(l : List α)
[Inhabited α]
{n : ℕ}
(hn : List.length l ≤ n)
:
theorem
List.getI_append_right
{α : Type u}
[Inhabited α]
(l : List α)
(l' : List α)
(n : ℕ)
(h : List.length l ≤ n)
:
theorem
List.getI_eq_iget_get?
{α : Type u}
(l : List α)
[Inhabited α]
(n : ℕ)
:
List.getI l n = Option.iget (List.get? l n)
theorem
List.getI_zero_eq_headI
{α : Type u}
(l : List α)
[Inhabited α]
:
List.getI l 0 = List.headI l