@[irreducible]
def
Array.foldlWith'
{α : Type u_1}
{β : Type u_2}
(xs : Array α)
(f : β → (x : α) → x ∈ xs → β)
(z : β)
(i : ℕ)
:
β
Equations
- xs.foldlWith' f z i = if h : i < xs.size then xs.foldlWith' f (f z xs[i] ⋯) (i + 1) else z
Instances For
def
Array.foldlWith
{α : Type u_1}
{β : Type u_2}
(xs : Array α)
(f : β → (x : α) → x ∈ xs → β)
(z : β)
:
β
Equations
- xs.foldlWith f z = xs.foldlWith' f z 0
Instances For
noncomputable def
Array.dfltMapWith
{α : Type u_1}
{β : Type u_2}
{xs : Array α}
(f : (x : α) → x ∈ xs → β)
(h : xs ≠ #[])
:
β
Equations
- Array.dfltMapWith f_2 h_2 = ⋯.elim
- Array.dfltMapWith f_2 h_2 = ⋯.some
Instances For
@[simp]
theorem
Array.foldlWith_eq_foldl_toList
{α : Type u_1}
{β : Type u_2}
{xs : Array α}
[ha : DecidableEq α]
{f : β → (x : α) → x ∈ xs → β}
{z : β}
:
xs.foldlWith f z = List.foldl (fun (acc : β) (x : α) => if h : x ∈ xs then f acc x h else z) z xs.toList