PRELUDE: add getLastX
This commit is contained in:
parent
cc7efa9906
commit
378f7887d4
@ -34,6 +34,13 @@ sortLex =
|
|||||||
x -> x)
|
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
|
-- |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.
|
-- than 2 elements in the list, return an empty list.
|
||||||
tailInit :: [a] -> [a]
|
tailInit :: [a] -> [a]
|
||||||
|
Loading…
Reference in New Issue
Block a user