Equations
- instReprVector = { reprPrec := reprVector✝ }
Equations
Custom eliminator for Vector α n
through Array α
Equations
- Vector.elimAsArray mk { toArray := xs, size_toArray := h } = mk xs h
Custom eliminator for Vector α n
through List α
Equations
- Vector.elimAsList mk { toList := xs, size_toArray := ha } = mk xs 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 }
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.
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
- xs.setIfInBounds i x = { toArray := xs.setIfInBounds i x, size_toArray := ⋯ }
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
- Vector.foldlM f b xs = Array.foldlM f b xs.toArray
Equations
- Vector.foldrM f b xs = Array.foldrM f b xs.toArray
Equations
- Vector.foldl f b xs = Array.foldl f b xs.toArray
Equations
- Vector.foldr f b xs = Array.foldr f b xs.toArray
Equations
- Vector.instHAppendHAddNat = { hAppend := Vector.append }
Creates a vector from another with a provably equal length.
Equations
- Vector.cast h xs = { toArray := xs.toArray, size_toArray := ⋯ }
Extract the first i
elements of a vector. If i
is greater than or equal to the size of the
vector then the vector is returned unchanged.
Maps elements of a vector using the function f
, which also receives the index of the element.
Equations
- Vector.mapIdx f xs = { toArray := Array.mapIdx f xs.toArray, size_toArray := ⋯ }
Map a monadic function over a vector.
Equations
- Vector.mapM f xs = Vector.mapM.go f xs 0 ⋯ { toArray := #[], size_toArray := ⋯ }
Equations
- Vector.mapM.go f xs k h acc = if h' : k < n then do let __do_lift ← f xs[k] Vector.mapM.go f xs (k + 1) ⋯ (acc.push __do_lift) else pure (Vector.cast ⋯ acc)
Equations
- Vector.flatMapM.go xs f i h acc = if h' : i < n then do let __do_lift ← f xs[i] Vector.flatMapM.go xs f (i + 1) ⋯ (Vector.cast ⋯ (acc ++ __do_lift)) else pure (Vector.cast ⋯ acc)
Variant of mapIdxM
which receives the index i
along with the bound `i < n.
Equations
- xs.mapFinIdxM f = Vector.mapFinIdxM.map xs f n 0 ⋯ (Vector.cast ⋯ { toArray := #[], size_toArray := ⋯ })
Equations
- Vector.mapFinIdxM.map xs f 0 j x ys_2 = pure ys_2
- Vector.mapFinIdxM.map xs f i_2.succ j inv_2 ys_2 = do let __do_lift ← f j xs[j] ⋯ Vector.mapFinIdxM.map xs f i_2 (j + 1) ⋯ (Vector.cast ⋯ (ys_2.push __do_lift))
Equations
- Vector.firstM f xs = Array.firstM f xs.toArray
Equations
Maps corresponding elements of two vectors of equal size using the function f
.
Equations
- Vector.zipWith f as bs = { toArray := Array.zipWith f as.toArray bs.toArray, 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.
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
- xs.swapIfInBounds i j = { toArray := xs.swapIfInBounds 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.
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.
The vector #v[0, 1, 2, ..., n-1]
.
Equations
- Vector.range n = { toArray := Array.range n, size_toArray := ⋯ }
The vector #v[start, start + step, start + 2 * step, ..., start + (size - 1) * step]
.
Equations
- Vector.range' start size step = { toArray := Array.range' start size step, size_toArray := ⋯ }
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
.
Delete an element of a vector using a Nat
index. Panics if the index is out of bounds.
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
- xs.finIdxOf? x = Option.map (Fin.cast ⋯) (xs.finIdxOf? x)
Equations
Finds the first index of a given value in a vector using a predicate. Returns none
if the
no element of the index matches the given value.
Equations
- Vector.findFinIdx? p xs = Option.map (Fin.cast ⋯) (Array.findFinIdx? p xs.toArray)
Note that the universe level is contrained to Type
here,
to avoid having to have the predicate live in p : α → m (ULift Bool)
.
Equations
- Vector.findM? f as = Array.findM? f as.toArray
Equations
- Vector.findSomeM? f as = Array.findSomeM? f as.toArray
Note that the universe level is contrained to Type
here,
to avoid having to have the predicate live in p : α → m (ULift Bool)
.
Equations
- Vector.findRevM? f as = Array.findRevM? f as.toArray
Equations
- Vector.findSomeRevM? f as = Array.findSomeRevM? f as.toArray
Equations
- Vector.find? f as = Array.find? f as.toArray
Equations
- Vector.findRev? f as = Array.findRev? f as.toArray
Equations
- Vector.findSome? f as = Array.findSome? f as.toArray
Equations
- Vector.findSomeRev? f as = Array.findSomeRev? f as.toArray
Returns true
when xs
is a prefix of the vector ys
.
Equations
- xs.isPrefixOf ys = xs.isPrefixOf ys.toArray
Returns true
with the monad if p
returns true
for any element of the vector.
Equations
- Vector.anyM p xs = Array.anyM p xs.toArray
Returns true
with the monad if p
returns true
for all elements of the vector.
Equations
- Vector.allM p xs = Array.allM p xs.toArray
Count the number of elements of a vector that satisfy the predicate p
.
Equations
- Vector.countP p xs = Array.countP p xs.toArray
Count the number of elements of a vector that are equal to a
.
Equations
- Vector.count a xs = Array.count a xs.toArray
Pad a vector on the left with a given element.
Note that we immediately simplify this to an ++
operation,
and do not provide separate verification theorems.
Equations
- Vector.leftpad n a xs = Vector.cast ⋯ (Vector.mkVector (n - m) a ++ xs)
Pad a vector on the right with a given element.
Note that we immediately simplify this to an ++
operation,
and do not provide separate verification theorems.
Equations
- Vector.rightpad n a xs = Vector.cast ⋯ (xs ++ Vector.mkVector (n - m) a)
ForIn instance #
Equations
- One or more equations did not get rendered due to their size.
ForM instance #
Equations
- Vector.instForM = { forM := fun [Monad m] => Vector.forM }
ToStream instance #
Equations
- Vector.instToStreamSubarray = { toStream := fun (xs : Vector α n) => xs.toSubarray 0 n }
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.