PRELUDE: add getLastX

This commit is contained in:
hasufell 2014-10-12 03:00:55 +02:00
parent cc7efa9906
commit 378f7887d4
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,13 @@ sortLex =
x -> x)
-- |Get the last x elements of a list.
getLastX :: Int -> [a] -> [a]
getLastX a xs
| length xs < a = []
| otherwise = snd . splitAt (length xs - a) $ xs
-- |Get a list with it's head and last element cut. If there are less
-- than 2 elements in the list, return an empty list.
tailInit :: [a] -> [a]