Hi everyone, very noob question here:
– From the input list create an output list which contains local maxima - only the elements bigger than both predecessor and successor
localMaxima :: [Int] → [Int]
localMaxima [] = []
localMaxima [a] = []
localMaxima [a, b] = []
localMaxima (x:y:z:zs) = filter cond (x:y:z:zs)
where
cond y = (y > x) && (y > z)
GHCi returns:
*Main> localMaxima [1,2,85,3]
[]
I don’t understand how pattern matching is working inside filter.