From b3371d16f95349bfc6178144809ec41040338613 Mon Sep 17 00:00:00 2001 From: hasufell Date: Sun, 12 Oct 2014 02:31:08 +0200 Subject: [PATCH] PRELUDE: add seqList --- MyPrelude.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MyPrelude.hs b/MyPrelude.hs index 51c7a44..2742af5 100644 --- a/MyPrelude.hs +++ b/MyPrelude.hs @@ -45,3 +45,9 @@ tailInit xs -- |Apply a function to the first element of a tuple. first :: (a -> b) -> (a,c) -> (b,c) first f (x,y) = (f x, y) + + +-- |Sequentialize a list, such as: +-- [1, 2, 3, 4, 5] -> [[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5]] +seqList :: [a] -> [[a]] +seqList = reverse . takeWhile (not . null) . iterate init