chore: fix Vector.indexOf? (#6208)

Just a better defeq.
This commit is contained in:
Kim Morrison 2024-11-25 21:47:58 +11:00 committed by GitHub
parent 935fcfb6ec
commit 43dfc2a25f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -215,7 +215,7 @@ Compares two vectors of the same size using a given boolean relation `r`. `isEqv
`true` if and only if `r v[i] w[i]` is true for all indices `i`.
-/
@[inline] def isEqv (v w : Vector α n) (r : αα → Bool) : Bool :=
Array.isEqvAux v.toArray w.toArray (by simp) r 0 (by simp)
Array.isEqvAux v.toArray w.toArray (by simp) r n (by simp)
instance [BEq α] : BEq (Vector α n) where
beq a b := isEqv a b (· == ·)
@ -249,9 +249,7 @@ Finds the first index of a given value in a vector using `==` for comparison. Re
no element of the index matches the given value.
-/
@[inline] def indexOf? [BEq α] (v : Vector α n) (x : α) : Option (Fin n) :=
match v.toArray.indexOf? x with
| some res => some (res.cast v.size_toArray)
| none => none
(v.toArray.indexOf? x).map (Fin.cast v.size_toArray)
/-- Returns `true` when `v` is a prefix of the vector `w`. -/
@[inline] def isPrefixOf [BEq α] (v : Vector α m) (w : Vector α n) : Bool :=