- #1
anonymous_w
- 1
- 0
'Condition' is a function which determines whether an element of some type a satisfies some property, and returns True if only if it does. A polymorphic data type 'Condition a' is defined:
data Condition a = Con (a -> Bool)
Define a function minSol::Ord a => Condition a -> [a] -> Maybe a which takes a condition as its first argument, a list of possible solutions as its second argument, and returns the smallest solution found in the list which satisfies the condition. If no solution is found, the function should return the value Nothing.
I tried to use lambda but I'm not sure how to recursively apply it to every element in the list and I think the smallest element can be determined by (<) or min.
data Condition a = Con (a -> Bool)
Define a function minSol::Ord a => Condition a -> [a] -> Maybe a which takes a condition as its first argument, a list of possible solutions as its second argument, and returns the smallest solution found in the list which satisfies the condition. If no solution is found, the function should return the value Nothing.
I tried to use lambda but I'm not sure how to recursively apply it to every element in the list and I think the smallest element can be determined by (<) or min.