def
d_array.iterate_aux
{n : ℕ}
{α : fin n → Type u}
{β : Type w}
(a : d_array n α)
(f : Π (i : fin n), α i → β → β)
(i : ℕ) :
i ≤ n → β → β
Equations
- a.iterate_aux f (j + 1) h b = let i : fin n := ⟨j, h⟩ in f i (a.read i) (a.iterate_aux f j _ b)
- a.iterate_aux f 0 h b = b
def
d_array.iterate
{n : ℕ}
{α : fin n → Type u}
{β : Type w}
(a : d_array n α)
(b : β)
(f : Π (i : fin n), α i → β → β) :
β
Fold over the elements of the given array in ascending order. Has builtin VM implementation.
Equations
- a.iterate b f = a.iterate_aux f n d_array.iterate._proof_1 b
def
d_array.rev_iterate_aux
{n : ℕ}
{α : fin n → Type u}
{β : Type w}
(a : d_array n α)
(f : Π (i : fin n), α i → β → β)
(i : ℕ) :
i ≤ n → β → β
Equations
- a.rev_iterate_aux f (j + 1) h b = let i : fin n := ⟨j, h⟩ in a.rev_iterate_aux f j _ (f i (a.read i) b)
- a.rev_iterate_aux f 0 h b = b
def
d_array.rev_iterate
{n : ℕ}
{α : fin n → Type u}
{β : Type w}
(a : d_array n α)
(b : β)
(f : Π (i : fin n), α i → β → β) :
β
Equations
- a.rev_iterate b f = a.rev_iterate_aux f n d_array.rev_iterate._proof_1 b
Equations
- a.read i = d_array.read a i
Equations
- a.write i v = d_array.write a i v
def
array.iterate
{n : ℕ}
{α : Type u}
{β : Type v}
(a : array n α)
(b : β)
(f : fin n → α → β → β) :
β
Fold array starting from 0, folder function includes an index argument.
Equations
- a.iterate b f = d_array.iterate a b f
Map each element of the given array with an index argument.
Equations
- a.foreach f = d_array.foreach a f
Equations
- array.map₂ f a b = b.foreach (λ (i : fin n), f (a.read i))
def
array.rev_iterate
{n : ℕ}
{α : Type u}
{β : Type v}
(a : array n α)
(b : β)
(f : fin n → α → β → β) :
β
Equations
- a.rev_iterate b f = d_array.rev_iterate a b f
Equations
- a.rev_foldl b f = a.rev_iterate b (λ (_x : fin n), f)
push_back a v
pushes value v
to the end of the array. Has builtin VM implementation.
@[protected, instance]
Equations
- array.has_mem = {mem := array.mem α}
@[protected, instance]
Equations
@[protected, instance]
Equations
- array.decidable_eq = array.decidable_eq._proof_1.mpr (λ (a b : d_array n (λ (_x : fin n), α)), d_array.decidable_eq a b)