[ create a new paste ] login | about

Link: http://codepad.org/PL9JcBz5    [ raw code | output | fork ]

Haskell, pasted on Mar 12:
-- | localMax Given an entry list, it outputs the its list of local maxima.
-- A Local maximum is a an element greater than its predecessor and than its
-- successor.
--
-- No point-free today, at least for my solution.
--
-- Examples:
--
-- >>> localMax [0 .. 1000]
-- []
--
-- >>> localMax [1000 .. 0]
-- []
--
-- >>> localMax [2,2,1,5,4]
-- [5]
--
-- >>> take 4 . localMax $ [0..] >>= (\y -> [y,y+2])
-- [2,3,4,5]
--
localMax :: Ord a => [a] -> [a]
localMax = undefined

main = print $ localMax [2,2,1,5,4] -- [5]


Output:
1
2

Program error: Prelude.undefined


Create a new paste based on this one


Comments: