I am trying to write a function using recursion eval :: Int -> Bool that returns true if given a list where every odd number is greater than ten. For example:
eval [] == True
eval [1] == False
eval [2] == True
eval [1, 11, 21] == False
eval [2, 12, 22] == True
eval [21, 11] == True
I have to use recursion to do it, and I have got a base code:
eval :: [Int] -> Bool
eval [] = True
eval (x:xs) | mod x 2/= 0 && x > 10 = True
| otherwise = eval xs
The code runs, but it does not work for lists with an odd number greater than 10 as the first input, as it takes the first value of the list as the standard. I think that sorting the list in ascending order first, then performing the recursion would work, is that correct and if so how do I go about implementing it?