Since I'm pretty sure that using global variables in Haskell is frowned upon. I'm wondering is there anyway I can achieve the following?
-- list has elements that are odd
listHasOdd :: [Integer] -> Bool
-- list has elements that are even
listHasEven :: [Integer] -> Bool
--list has a length > 5
longList :: [Integer] -> Bool
-- Maps the function to a [Bool]
-- This function cannot be modified to fix the problem.
checkList :: [Integer] -> [Bool]
checkList xs = map (\ y -> y xs) listChecker
where listChecker = [listHasOdd, listHasEven, longList]
Is there anyway that I can ensure that only one of them returns true?
For example, [1,2,3,5], I would want only want listHasOdd to return True which is [True, False, False]. (Evaluated from top to bottom).
Another example, [2,4,6,8,10,12,14], the returns should be [False, True, False].
In other words, checkList [1,2,3,5] returns [True, False, False], checkList[2,4,6,8,10,12,14] returns [False, True, False]
**The last function would always be False in my example, since it is unreachable.
I know I can do an if statement to check if the previous one is True
but that seems like a pretty dumb idea. Or is that actually the way to do it? (Considering Haskell "remembers" the results of the previous function)