1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-08 01:26:57 +02:00
CodeWars/7kyu/exes_and_ohs/solution.hs
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

13 lines
354 B
Haskell

module Codewars.Kata.XO where
import Data.Char
-- | Returns true if the number of
-- Xs is equal to the number of Os
-- (case-insensitive)
xo :: String -> Bool
xo str = xs == os
where counter (x, o) 'x' = (x + 1, o)
counter (x, o) 'o' = (x, o + 1)
counter counts _ = counts
(xs, os) = foldl counter (0, 0) $ map toLower str