-- Count the number of times a predicate is true

count :: (a -> Bool) -> [a] -> Int
count p = go 0
  where go !n [] = n
        go !n (x:xs) | p x       = go (n+1) xs
                     | otherwise = go n xs

{-
@splitAt@, @take@, and @drop@ but with length of another
list giving the break-off point:
-}
count :: (a -> Bool) -> [a] -> Int
count p = go 0
  where go !n [] = n
        go !n (x:xs) | p x       = go (n+1) xs
                     | otherwise = go n xs

{-
@splitAt@, @take@, and @drop@ but with length of another
list giving the break-off point:
-}
count p = go 0
  where go !n [] = n
        go !n (x:xs) | p x       = go (n+1) xs
                     | otherwise = go n xs

{-
@splitAt@, @take@, and @drop@ but with length of another
list giving the break-off point:
-}