The type Vector
represents lists with fixed length.
Equations
- Vector.instDecidableEq = inferInstanceAs (DecidableEq { l : List α // l.length = n })
If a : α
and l : Vector α n
, then cons a l
, is the vector of length n + 1
whose first element is a and with l as the rest of the list.
Equations
- Vector.cons x✝ x = match x✝, x with | a, ⟨v, h⟩ => ⟨a :: v, ⋯⟩
Instances For
The head of a vector obtained by prepending is the element prepended.
The tail of a vector obtained by prepending is the vector prepended. to
Prepending the head of a vector to its tail gives the vector.
Map a vector under a function.
Equations
- Vector.map f x = match x with | ⟨l, h⟩ => ⟨List.map f l, ⋯⟩
Instances For
Mapping two vectors under a curried function of two variables.
Equations
- Vector.map₂ f x✝ x = match x✝, x with | ⟨x, property⟩, ⟨y, property_1⟩ => ⟨List.zipWith f x y, ⋯⟩
Instances For
Vector obtained by repeating an element.
Equations
- Vector.replicate n a = ⟨List.replicate n a, ⋯⟩
Instances For
Remove the element at position i
from a vector of length n
.
Equations
- Vector.eraseIdx i x = match x with | ⟨l, p⟩ => ⟨l.eraseIdx ↑i, ⋯⟩
Instances For
Alias of Vector.eraseIdx
.
Remove the element at position i
from a vector of length n
.
Equations
Instances For
Vector of length n
from a function on Fin n
.
Equations
- Vector.ofFn x_2 = Vector.nil
- Vector.ofFn f = Vector.cons (f 0) (Vector.ofFn fun (i : Fin n) => f i.succ)
Instances For
Create a vector from another with a provably equal length.
Equations
- Vector.congr h x = match x with | ⟨x, p⟩ => ⟨x, ⋯⟩
Instances For
Runs a function over a vector returning the intermediate results and a final result.
Equations
- Vector.mapAccumr f x✝ x = match x✝, x with | ⟨x, px⟩, c => let res := List.mapAccumr f x c; (res.fst, ⟨res.snd, ⋯⟩)
Instances For
Runs a function over a pair of vectors returning the intermediate results and a final result.
Equations
- Vector.mapAccumr₂ f x✝¹ x✝ x = match x✝¹, x✝, x with | ⟨x, px⟩, ⟨y, py⟩, c => let res := List.mapAccumr₂ f x y c; (res.fst, ⟨res.snd, ⋯⟩)
Instances For
Shift Primitives #
shiftLeftFill v i
is the vector obtained by left-shifting v
i
times and padding with the
fill
argument. If v.length < i
then this will return replicate n fill
.
Equations
- v.shiftLeftFill i fill = Vector.congr ⋯ ((Vector.drop i v).append (Vector.replicate (min n i) fill))
Instances For
shiftRightFill v i
is the vector obtained by right-shifting v
i
times and padding with the
fill
argument. If v.length < i
then this will return replicate n fill
.
Equations
- v.shiftRightFill i fill = Vector.congr ⋯ ((Vector.replicate (min n i) fill).append (Vector.take (n - i) v))
Instances For
Basic Theorems #
Vector of length from a list v
with witness that v
has length n
maps to v
under toList
.
A nil vector maps to a nil list.