on master help sign in
Add scanl for Vect.
0661ec0Greg Pfeil
libs/prelude/Prelude/Vect.idr+8
@@ -254,6 +254,14 @@ concat : Vect m (Vect n a) -> Vect (m * n) a
254concat [] = []
254concat [] = []
255concat (v::vs) = v ++ concat vs
255concat (v::vs) = v ++ concat vs
256
256
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+
257--------------------------------------------------------------------------------
265--------------------------------------------------------------------------------
258-- Membership tests
266-- Membership tests
259--------------------------------------------------------------------------------
267--------------------------------------------------------------------------------