on master help sign in
Add scanl for Vect.
commit0661ec0bda1996e37fa3ea57b87811925c17a565 authorGreg Pfeil <greg@technomadic.org> dateSun 13 Apr 2014, 12:34 (13 years ago) parentb283c0d
1 file changed+8
libs/prelude/Prelude/Vect.idr+8
libs/prelude/Prelude/Vect.idr+8
@@ -254,6 +254,14 @@ concat : Vect m (Vect n a) -> Vect (m * n) a
254254concat [] = []
255255concat (v::vs) = v ++ concat vs
256256
257+--------------------------------------------------------------------------------
258+-- Scans
259+--------------------------------------------------------------------------------
260+
261+scanl : (b -> a -> b) -> b -> Vect n a -> Vect (S n) b
262+scanl f q [] = [q]
263+scanl f q (x::xs) = q :: scanl f (f q x) xs
264+
257265--------------------------------------------------------------------------------
258266-- Membership tests
259267--------------------------------------------------------------------------------