nums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]
howManyEvens = length(removeOdd(nums))
isItOk count
| count > 10 = "Too much"
| count > 8 = "Isn't this a little much?"
| count > 5 = "I think this is ok"
| count > 3 = "Little more please"
| count > 0 = "Ooo, cmon"
| otherwise = "We gonna die"
result = isItOk howManyEvens
isItOk' nums = case (length(removeOdd(nums))) of
10 -> "Too much"
8 -> "Isn't this a little much?"
5 -> "I think this is ok"
3 -> "Little more please"
0 -> "Ooo, cmon"
x -> "i don't even"
So the only different thing is i didn't need to create howManyEvens constant.
PS: While i writing this. I realized that with case, i need to use pattern matching but with guards i can use other functions if i wanted to. ( like count > 10 )
To the authors : Please, if you writing a book a blog post about haskell. Don't create same function in different styles. We don't understand which one we need to use and why we have all different choices.
Thanks.