Decide whether the items in the list all give the same remainder divided by two.
My code is working when the mod is 1, but it is not working when the mod is 0. What do I have to add to work? An if - else statement or something else?
sameParity :: [Int] -> Bool
sameParity [] = True
sameParity (x: xs)
| x `mod` 2 == 1 = sameParity xs
| x `mod` 2 == 0 = sameParity xs
| otherwise = False
Examples:
Each of the following test cases must give a True:
sameParity [] == True
sameParity [1..10] == False
sameParity [1,3..10] == True
sameParity [2, 42, 0, 8] == True
sameParity (1: [2, 42, 0, 8]) == False