@[inline]
In-place update of the element at index i via f, wrapping Array.modify
so the underlying swap-with-placeholder ownership transfer survives codegen.
Calling xs.set i (f xs[i]) forces a lean_inc on the borrowed entry and
loses uniqueness on nested-array shapes (e.g. matrix rows); modify avoids
that copy when xs is uniquely owned.
Instances For
theorem
Vector.getElem_foldl_modify_not_mem
{n : Nat}
{α : Type u_1}
(g : Fin n → α → α)
{r : Nat}
(hr : r < n)
(xs : List (Fin n))
(v0 : Vector α n)
:
A left fold of per-index modifys over a list of Fin n indices leaves
index r untouched when r is not among the folded indices. The backing engine
for the in-place indexed row scatter (Matrix.mapRowsIdx).
theorem
Vector.getElem_finFoldl_modify
{α : Type u_1}
{n : Nat}
(v0 : Vector α n)
(g : Fin n → α → α)
(r : Fin n)
:
Reading index r of a Fin.foldl of per-index modifys yields g r
applied to the original entry — every index is visited exactly once. This is the
in-place (no intermediate List.finRange allocation) scatter form.