re: Daily Challenge #29 - Xs and Os VIEW POST

FULL DISCUSSION
 

Haskell again

import Data.Char (toLower)

compare_xos :: String -> Bool
compare_xos = same . foldl kevin (0, 0)
  where
    kevin (x, o) c
      | toLower c == 'x' = (x + 1, o)
      | toLower c == 'o' = (x, o + 1)
      | otherwise        = (x, o)
    same (x, o) = x == o
 

Just being able to use Haskell impresses me lol

 

I can't do anything useful with it yet, but it's fun to solve coding katas :D.

 
code of conduct - report abuse