Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- splitList :: [a] -> [[a]]
- splitList [] = [[]]
- splitList list = scanr (\elem new -> [elem] ++ new) [] list
- selectFirst:: Int -> [[a]] -> [[a]]
- selectFirst n [[]] = [[]]
- selectFirst n list = map (take n) (filter (\l -> length l >= 3) list)
- cmpElem::(a -> a -> Bool) -> a -> a -> a -> Bool
- cmpElem f a b c = (f a b) && (f c b)
- localMaxima :: [Integer] -> [Integer]
- localMaxima l = let split_list = splitList l
- three_elem_list = selectFirst 3 split_list
- valid_elem_list = filter (\[a, b, c] -> cmpElem (<) a b c) three_elem_list
- in map (\[a, b, c] -> b) valid_elem_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement