Reputation: 35
addDivide n = if sum n / 5 then True else False
I am trying to get the sum of a list then see if the sum is divisible by a certain number
eg. [5,5] = 10/5 = 2
Upvotes: 0
Views: 142
Reputation: 477160
You can check if an Integral
number a
is dividable by 5, by check if n `mod` 5 == 0
.
You thus can check this with:
addDivide :: (Foldable f, Integral a) => f a -> Bool
addDivide xs = sum xs `mod` 5 == 0
Upvotes: 1