PRELUDE: add dupLast

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

View File

@ -51,3 +51,9 @@ first f (x,y) = (f x, y)
-- [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
-- |Duplicate the last element of a list and append it.
dupLast :: [a] -> [a]
dupLast [] = []
dupLast xs = xs ++ [last xs]