Search code examples
haskellminimum

Elements of list smaller than some value


I need to calculate the minimum of a list but im trying to do it on this Type declaration
Ord a => a ‐> [a] ‐> [a]
which computes the list of those elements of the given list which are smaller than a
given argument (first argument of the function)

mymin :: Ord a => a-> [a] -> [a]

mymin (x:y:xs)   
        | x > y : mymin(y,xs)  
            |otherwise 

Solution

  • Just use filter. It was made for filtering lists:

    mymin :: Ord a => a -> [a] -> [a]
    mymin x = filter (< x)