I have two functions. The first one gives true if all elements of the list are zero
allZero :: [Int] -> Bool
allZero [] = False
allZero [0] = True
allZero (x:xs)
| x == 0 && allZero xs = True
|otherwise = False
The second function gives true if at least one element of the list is zero
oneZero :: [Int] -> Bool
oneZero [] = False
oneZero (x:xs)
| x == 0 = True
| otherwise = oneZero xs
Maybe there is another way to solve this problems. For example with map or foldr? Thank you
anyandallin terms offoldr? - Willem Van OnsemallZero [] = Falseis surprising. Are you sure you don't wantTruein that case, as your informal specification implies? - chiallZero (x:xs) = x == 0 && allZero xs.oneZero (x:xs) = x == 0 || oneZero xs.allZero = all . map (== 0).oneZero = any . map (== 0).all == foldr (&&) True.any == foldr (||) False. <meta> (this is not a full answer as it has no words in it, hence it is left as a comment.) </meta> - Will Ness