PRELUDE: add seqList

This commit is contained in:
hasufell 2014-10-12 02:31:08 +02:00
parent 6dc4fae415
commit b3371d16f9
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 6 additions and 0 deletions

View File

@ -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