on master help sign in
Add the Vect version of dropElem.

Inspired by the request from Kevin Meredith in the Idris mailing list for an implementation of removeElem [1]. This borrows directly from the existing work in the List implementation and the work in 'Type-Driven Development with Idris' by Edwin Brady. [1]: https://groups.google.com/d/msg/idris-lang/UKhvTKS6TfE/MEK9akzYBwAJ

commit20ee4d5a090cf0c85c7651b806cf9f66804faf60 authorCaleb Case <calebcase@gmail.com> dateWed 18 Oct 2017, 06:58 (9 years ago) parent9e1c9a3
2 files changed+9
CONTRIBUTORS+1 libs/base/Data/Vect.idr+8
CONTRIBUTORS+1
@@ -34,6 +34,7 @@ Brent Yorgey
3434Brian Koropoff
3535Brian McKenna
3636Bryn Keller
37+Caleb Case
3738Calvin Beck
3839Carsten König
3940Carter Charbonneau
libs/base/Data/Vect.idr+8
@@ -634,6 +634,14 @@ mapElem : {xs : Vect k t} -> {f : t -> u} -> Elem x xs -> Elem (f x) (map f xs)
634634mapElem Here = Here
635635mapElem (There e) = There (mapElem e)
636636
637+||| Remove the element at the given position.
638+|||
639+||| @xs The vector to be removed from
640+||| @p A proof that the element to be removed is in the vector
641+dropElem : (xs : Vect (S k) t) -> (p : Elem x xs) -> Vect k t
642+dropElem (x :: ys) Here = ys
643+dropElem {k = (S k)} (x :: ys) (There later) = x :: dropElem ys later
644+
637645-- Some convenience functions for testing lengths
638646
639647||| If the given Vect is the required length, return a Vect with that