diff --git a/MyPrelude.hs b/MyPrelude.hs index 2742af5..f234a19 100644 --- a/MyPrelude.hs +++ b/MyPrelude.hs @@ -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]