PRELUDE: add seqList
This commit is contained in:
parent
6dc4fae415
commit
b3371d16f9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user