on master help sign in
Add splitAt to Vect
commit2f58e16866d5c074a160a08d7c6c448f082d1b36 authorJean-Remi Desjardins <jeanremi.desjardins@gmail.com> dateWed 2 Apr 2014, 16:36 (13 years ago) parent53a5014
1 file changed+8
libs/prelude/Prelude/Vect.idr+8
libs/prelude/Prelude/Vect.idr+8
@@ -381,6 +381,14 @@ nub = nubBy (==)
381381-- Splitting and breaking lists
382382--------------------------------------------------------------------------------
383383
384+||| A tuple where the first element is a Vect of the n first elements and
385+||| the second element is a Vect of the remaining elements of the original Vect
386+||| It is equivalent to (take n xs, drop n xs)
387+||| @ m the index to split at
388+||| @ xs the Vect to split in two
389+splitAt : {n : Nat} -> (m : Fin (S n)) -> (xs : Vect n a) -> (Vect (cast m) a, Vect (n - cast m) a)
390+splitAt n xs = (take n xs, drop n xs)
391+
384392--------------------------------------------------------------------------------
385393-- Predicates
386394--------------------------------------------------------------------------------