Reputation: 13
I would expect
input : maxNumbers 5 [1,4,5,6,8,4,5,8]
output : [6,8,8]
My Approach:
maxNumbers ::a =>[a] -> [a]
maxNumbers n (x:xs) = enumFrom(n < x) + maxNumbers n xs
Upvotes: 0
Views: 164
Reputation: 1421
What is lacking in your signature is a way to tell haskell that the elements in your list can be ordered (the Ord
typeclass). This is not true for every type so you have to take that into account.
maxNumbers :: Ord a => a -> [a] -> [a]
maxNumbers x = filter (>x)
Is an implementation that should work.
Upvotes: 5