Syntax for Vector α n
Equations
- One or more equations did not get rendered due to their size.
Instances For
Custom eliminator for Vector α n
through Array α
Equations
- Vector.elimAsArray mk { toArray := a, size_toArray := ha } = mk a ha
Instances For
Make an empty vector with pre-allocated capacity.
Instances For
Makes a vector of size n
with all cells containing v
.
Equations
- Vector.mkVector n v = { toArray := mkArray n v, size_toArray := ⋯ }
Instances For
Returns a vector of size 1
with element v
.
Equations
- Vector.singleton v = { toArray := #[v], size_toArray := ⋯ }
Instances For
Set an element in a vector using a Nat
index, with a tactic provided proof that the index is in
bounds.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.set i x h = { toArray := v.set i x ⋯, size_toArray := ⋯ }
Instances For
Set an element in a vector using a Nat
index. Returns the vector unchanged if the index is out of
bounds.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.setIfInBounds i x = { toArray := v.setIfInBounds i x, size_toArray := ⋯ }
Instances For
Extracts the slice of a vector from indices start
to stop
(exclusive). If start ≥ stop
, the
result is empty. If stop
is greater than the size of the vector, the size is used instead.
Equations
- v.extract start stop = { toArray := v.extract start stop, size_toArray := ⋯ }
Instances For
Maps corresponding elements of two vectors of equal size using the function f
.
Equations
- a.zipWith b f = { toArray := a.zipWith b.toArray f, size_toArray := ⋯ }
Instances For
Swap two elements of a vector using Fin
indices.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.swap i j hi hj = { toArray := v.swap i j ⋯ ⋯, size_toArray := ⋯ }
Instances For
Swaps an element of a vector with a given value using a Fin
index. The original value is returned
along with the updated vector.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.swapAt i x hi = ((v.swapAt i x ⋯).fst, { toArray := (v.swapAt i x ⋯).snd, size_toArray := ⋯ })
Instances For
Swaps an element of a vector with a given value using a Nat
index. Panics if the index is out of
bounds. The original value is returned along with the updated vector.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.swapAt! i x = ((v.swapAt! i x).fst, { toArray := (v.swapAt! i x).snd, size_toArray := ⋯ })
Instances For
Extract the first m
elements of a vector. If m
is greater than or equal to the size of the
vector then the vector is returned unchanged.
Equations
- v.take m = { toArray := v.take m, size_toArray := ⋯ }
Instances For
Deletes the first m
elements of a vector. If m
is greater than or equal to the size of the
vector then the empty vector is returned.
Equations
- v.drop m = { toArray := v.extract m v.size, size_toArray := ⋯ }
Instances For
Delete an element of a vector using a Nat
index. Panics if the index is out of bounds.
Equations
- v.eraseIdx! i = if x : i < n then v.eraseIdx i x else let_fun this := { default := v.pop }; panicWithPosWithDecl "Init.Data.Vector.Basic" "Vector.eraseIdx!" 235 4 "index out of bounds"
Instances For
Delete the first element of a vector. Returns the empty vector if the input vector is empty.
Equations
- v.tail = if x : 0 < n then v.eraseIdx 0 x else Vector.cast ⋯ v