Equations
- Batteries.instReprVector = { reprPrec := Batteries.reprVector✝ }
Equations
- Batteries.instDecidableEqVector = Batteries.decEqVector✝
Alias of Batteries.Vector.size_toArray
.
Array size.
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
- Batteries.Vector.elimAsArray mk { toArray := a, size_toArray := ha } = mk a ha
Instances For
Custom eliminator for Vector α n
through List α
Equations
- Batteries.Vector.elimAsList mk { toList := a, size_toArray := ha } = mk a ha
Instances For
The empty vector.
Equations
- Batteries.Vector.empty = { toArray := #[], size_toArray := ⋯ }
Instances For
Make an empty vector with pre-allocated capacity.
Equations
- Batteries.Vector.mkEmpty capacity = { toArray := Array.mkEmpty capacity, size_toArray := ⋯ }
Instances For
Makes a vector of size n
with all cells containing v
.
Equations
- Batteries.Vector.mkVector n v = { toArray := mkArray n v, size_toArray := ⋯ }
Instances For
Returns a vector of size 1
with element v
.
Equations
- Batteries.Vector.singleton v = { toArray := #[v], size_toArray := ⋯ }
Instances For
Equations
- Batteries.Vector.instInhabited = { default := Batteries.Vector.mkVector n default }
Get an element of a vector using a USize
index and a proof that the index is within bounds.
Equations
- v.uget i h = v.uget i ⋯
Instances For
Equations
- Batteries.Vector.instGetElemNatLt = { getElem := fun (x : Batteries.Vector α n) (i : Nat) (h : i < n) => x.get ⟨i, h⟩ }
Get an element of a vector using a Nat
index. Returns the given default value if the index is out
of bounds.
Equations
- v.getD i default = v.getD i default
Instances For
The last element of a vector. Panics if the vector is empty.
Equations
- v.back! = v.back!
Instances For
The last element of a vector, or none
if the array is empty.
Equations
- v.back? = v.back?
Instances For
Push an element x
to the end of a vector.
Equations
- Batteries.Vector.push x v = { toArray := v.push x, size_toArray := ⋯ }
Instances For
Remove the last element of a vector.
Equations
- v.pop = { toArray := v.pop, size_toArray := ⋯ }
Instances For
Set an element in a vector using a Fin
index.
This will perform the update destructively provided that the vector has a reference count of 1.
Instances For
Set an element in a vector using a Nat
index. By default, the get_elem_tactic
is used to
synthesize a proof that the index is within bounds.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.setN i x h = { toArray := v.setN 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.setD i x = { toArray := v.setD i x, size_toArray := ⋯ }
Instances For
Set an element in a vector using a Nat
index. Panics 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.set! i x = { toArray := v.set! i x, size_toArray := ⋯ }
Instances For
Append two vectors.
Instances For
Equations
- Batteries.Vector.instHAppendHAddNat = { hAppend := Batteries.Vector.append }
Creates a vector from another with a provably equal length.
Equations
- Batteries.Vector.cast h v = { toArray := v.toArray, 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 elements of a vector using the function f
.
Equations
- Batteries.Vector.map f v = { toArray := Array.map f v.toArray, 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
The vector of length n
whose i
-th element is f i
.
Equations
- Batteries.Vector.ofFn f = { toArray := Array.ofFn 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.
Instances For
Swap two elements of a vector using Nat
indices. By default, the get_elem_tactic
is used to
synthesize proofs that the indices are within bounds.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.swapN i j hi hj = { toArray := v.swapN i j ⋯ ⋯, size_toArray := ⋯ }
Instances For
Swap two elements of a vector using Nat
indices. Panics if either index is out of bounds.
This will perform the update destructively provided that the vector has a reference count of 1.
Equations
- v.swap! i j = { 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
Instances For
Swaps an element of a vector with a given value using a Nat
index. By default, the
get_elem_tactic
is used to synthesise a proof that the index is within 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.swapAtN i x h = ((v.swapAtN i x ⋯).fst, { toArray := (v.swapAtN 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
The vector #v[0,1,2,...,n-1]
.
Equations
- Batteries.Vector.range n = { toArray := Array.range n, 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
Alias of Batteries.Vector.take
.
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.
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
Compares two vectors of the same size using a given boolean relation r
. isEqv v w r
returns
true
if and only if r v[i] w[i]
is true for all indices i
.
Equations
- v.isEqv w r = v.isEqvAux w.toArray ⋯ r n ⋯
Instances For
Equations
- Batteries.Vector.instBEq = { beq := fun (a b : Batteries.Vector α n) => a.isEqv b fun (x1 x2 : α) => x1 == x2 }
Reverse the elements of a vector.
Equations
- v.reverse = { toArray := v.reverse, size_toArray := ⋯ }
Instances For
Delete an element of a vector using a Fin
index.
Instances For
Delete an element of a vector using a Nat
index. Panics if the index is out of bounds.
Equations
- One or more equations did not get rendered due to their size.
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 { toArray := v.eraseIdx 0, size_toArray := ⋯ } else Batteries.Vector.cast ⋯ v
Instances For
Delete an element of a vector using a Nat
index. By default, the get_elem_tactic
is used to
synthesise a proof that the index is within bounds.
Equations
- v.eraseIdxN i h = { toArray := v.eraseIdxN i ⋯, size_toArray := ⋯ }
Instances For
Finds the first index of a given value in a vector using ==
for comparison. Returns none
if the
no element of the index matches the given value.
Equations
- v.indexOf? x = Option.map (Fin.cast ⋯) (v.indexOf? x)
Instances For
Returns true
when v
is a prefix of the vector w
.
Equations
- v.isPrefixOf w = v.isPrefixOf w.toArray
Instances For
Returns true
when all elements of the vector are pairwise distinct using ==
for comparison.
Equations
- as.allDiff = as.allDiff