Equations
- instReprVector = { reprPrec := reprVector✝ }
Equations
Syntax for Vector α n
Equations
- One or more equations did not get rendered due to their size.
Custom eliminator for Vector α n
through Array α
Equations
- Vector.elimAsArray mk { toArray := a, size_toArray := ha } = mk a ha
Custom eliminator for Vector α n
through List α
Equations
- Vector.elimAsList mk { toList := a, size_toArray := ha } = mk a ha
Make an empty vector with pre-allocated capacity.
Equations
- Vector.mkEmpty capacity = { toArray := Array.mkEmpty capacity, size_toArray := ⋯ }
Makes a vector of size n
with all cells containing v
.
Equations
- Vector.mkVector n v = { toArray := mkArray n v, size_toArray := ⋯ }
Returns a vector of size 1
with element v
.
Equations
- Vector.singleton v = { toArray := #[v], size_toArray := ⋯ }
Equations
- Vector.instInhabited = { default := Vector.mkVector n default }
Equations
- Vector.instMembership = { mem := Vector.Mem }
Push an element x
to the end of a vector.
Equations
- Vector.push x v = { toArray := v.push x, size_toArray := ⋯ }
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 := ⋯ }
Equations
- Vector.instHAppendHAddNat = { hAppend := Vector.append }
Creates a vector from another with a provably equal length.
Equations
- Vector.cast h v = { toArray := v.toArray, size_toArray := ⋯ }
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 := ⋯ }
Maps elements of a vector using the function f
.
Equations
- Vector.map f v = { toArray := Array.map f v.toArray, size_toArray := ⋯ }
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 := ⋯ }
The vector of length n
whose i
-th element is f i
.
Equations
- Vector.ofFn f = { toArray := Array.ofFn f, size_toArray := ⋯ }
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 := ⋯ }
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 := ⋯ })
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 := ⋯ })
The vector #v[0,1,2,...,n-1]
.
Equations
- Vector.range n = { toArray := Array.range n, size_toArray := ⋯ }
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 := ⋯ }
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 := ⋯ }
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!" 249 4 "index out of bounds"
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
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)
Returns true
with the monad if p
returns true
for any element of the vector.
Equations
- Vector.anyM p v = Array.anyM p v.toArray
Returns true
with the monad if p
returns true
for all elements of the vector.
Equations
- Vector.allM p v = Array.allM p v.toArray
Lexicographic ordering #
Lexicographic comparator for vectors.
lex v w lt
is true if
v
is pairwise equivalent via==
tow
, or- there is an index
i
such thatlt v[i] w[i]
, and for allj < i
,v[j] == w[j]
.
Equations
- One or more equations did not get rendered due to their size.