I implemented and
and or
:
-- or is like and, only it returns True if
-- any of the boolean values in a list is True.
or' :: [Bool] -> Bool
or' [] = False
or' (x:xs) = x || or' xs
--and takes a list of boolean values and returns True only if
-- all the values in the list are True.
and' :: [Bool] -> Bool
and' [] = False
and' (x:xs) = x && and' xs
Is pattern matching the most elegant solution here?
Also, should or' []
and and' []
return False
? It makes sense for them to do so when passing in a non-null input.
Example: or' [False, False]
But, how about the behavior of or' []
or and' []
? Does False
make sense here?