Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Find the last element of a list.
- one = last
- two xs = xs !! (length xs - 1)
- three = head . reverse
- four [x] = x
- four (x:xs) = four xs
- five xs
- | length xs == 1 = xs !! 0
- | otherwise = five (tail xs)
- six [x] = x
- six xs = six $ tail xs
- seven = head . aux
- where
- aux [] = []
- aux (x:xs) = aux xs ++ [x]
- eight = last . id
- nine xs =
- snd $
- head $ filter (\(a, b) -> a == 0) $ zip [length xs - 1,length xs - 2 .. 0] xs
- ten xs =
- (\[(a, b)] -> b) $ dropWhile (\(a, b) -> a < length xs - 1) $ zip [0 ..] xs
- eleven :: [a] -> a
- eleven = foldl1 (\x y -> y)
- twelve = head . scanr1 (\x y -> y)
- thirteen xs = (snd . maximum . zip [0 ..]) xs
- fourteen (x:xs) = aux x xs
- where
- aux y l@(z:zs) | null l = y
- | null zs = z
- | otherwise = aux z zs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement