modifyHead #
@[simp]
theorem
List.length_modifyHead
{α : Type u_1}
{f : α → α}
{l : List α}
:
(modifyHead f l).length = l.length
theorem
List.modifyHead_eq_set
{α : Type u_1}
[Inhabited α]
(f : α → α)
(l : List α)
:
modifyHead f l = l.set 0 (f (l[0]?.getD default))
@[simp]
theorem
List.modifyHead_eq_nil_iff
{α : Type u_1}
{f : α → α}
{l : List α}
:
modifyHead f l = [] ↔ l = []
@[simp]
theorem
List.modifyHead_modifyHead
{α : Type u_1}
{l : List α}
{f g : α → α}
:
modifyHead g (modifyHead f l) = modifyHead (g ∘ f) l
theorem
List.getElem_modifyHead
{α : Type u_1}
{l : List α}
{f : α → α}
{n : Nat}
(h : n < (modifyHead f l).length)
:
(modifyHead f l)[n] = if h' : n = 0 then f l[0] else l[n]
@[simp]
theorem
List.getElem_modifyHead_zero
{α : Type u_1}
{l : List α}
{f : α → α}
{h : 0 < (modifyHead f l).length}
:
(modifyHead f l)[0] = f l[0]
@[simp]
theorem
List.getElem_modifyHead_succ
{α : Type u_1}
{l : List α}
{f : α → α}
{n : Nat}
(h : n + 1 < (modifyHead f l).length)
:
(modifyHead f l)[n + 1] = l[n + 1]
theorem
List.getElem?_modifyHead
{α : Type u_1}
{l : List α}
{f : α → α}
{n : Nat}
:
(modifyHead f l)[n]? = if n = 0 then Option.map f l[n]? else l[n]?
@[simp]
theorem
List.getElem?_modifyHead_zero
{α : Type u_1}
{l : List α}
{f : α → α}
:
(modifyHead f l)[0]? = Option.map f l[0]?
@[simp]
theorem
List.getElem?_modifyHead_succ
{α : Type u_1}
{l : List α}
{f : α → α}
{n : Nat}
:
(modifyHead f l)[n + 1]? = l[n + 1]?
@[simp]
theorem
List.head_modifyHead
{α : Type u_1}
(f : α → α)
(l : List α)
(h : modifyHead f l ≠ [])
:
(modifyHead f l).head h = f (l.head ⋯)
@[simp]
theorem
List.head?_modifyHead
{α : Type u_1}
{l : List α}
{f : α → α}
:
(modifyHead f l).head? = Option.map f l.head?
@[simp]
theorem
List.tail_modifyHead
{α : Type u_1}
{f : α → α}
{l : List α}
:
(modifyHead f l).tail = l.tail
@[simp]
theorem
List.take_modifyHead
{α : Type u_1}
{f : α → α}
{l : List α}
{n : Nat}
:
take n (modifyHead f l) = modifyHead f (take n l)
@[simp]
theorem
List.drop_modifyHead_of_pos
{α : Type u_1}
{f : α → α}
{l : List α}
{n : Nat}
(h : 0 < n)
:
drop n (modifyHead f l) = drop n l
theorem
List.eraseIdx_modifyHead_zero
{α : Type u_1}
{f : α → α}
{l : List α}
:
(modifyHead f l).eraseIdx 0 = l.eraseIdx 0
@[simp]
theorem
List.eraseIdx_modifyHead_of_pos
{α : Type u_1}
{f : α → α}
{l : List α}
{n : Nat}
(h : 0 < n)
:
(modifyHead f l).eraseIdx n = modifyHead f (l.eraseIdx n)
modifyTailIdx #
@[simp]
theorem
List.eraseIdx_eq_modifyTailIdx
{α : Type u_1}
(n : Nat)
(l : List α)
:
l.eraseIdx n = modifyTailIdx tail n l
theorem
List.modifyTailIdx_add
{α : Type u_1}
(f : List α → List α)
(n : Nat)
(l₁ l₂ : List α)
:
modifyTailIdx f (l₁.length + n) (l₁ ++ l₂) = l₁ ++ modifyTailIdx f n l₂
theorem
List.modifyTailIdx_modifyTailIdx
{α : Type u_1}
{f g : List α → List α}
(m n : Nat)
(l : List α)
:
modifyTailIdx g (m + n) (modifyTailIdx f n l) = modifyTailIdx (fun (l : List α) => modifyTailIdx g m (f l)) n l
theorem
List.modifyTailIdx_modifyTailIdx_le
{α : Type u_1}
{f g : List α → List α}
(m n : Nat)
(l : List α)
(h : n ≤ m)
:
modifyTailIdx g m (modifyTailIdx f n l) = modifyTailIdx (fun (l : List α) => modifyTailIdx g (m - n) (f l)) n l
theorem
List.modifyTailIdx_modifyTailIdx_self
{α : Type u_1}
{f g : List α → List α}
(n : Nat)
(l : List α)
:
modifyTailIdx g n (modifyTailIdx f n l) = modifyTailIdx (g ∘ f) n l
modify #
theorem
List.modifyHead_eq_modify_zero
{α : Type u_1}
(f : α → α)
(l : List α)
:
modifyHead f l = modify f 0 l