add x (Node y left right) | x == y = Node y left right | x < y = Node y (add x left) right | otherwise = Node y left (add x right)
module Main where import System.Environment womenCount :: [[Char]] -> Int womenCount [] = 0 womenCount ([_,_,_,_,_,_,_,_,_,p,_]:xs) | elem p ['0','2','4','6','8'] = 1 + womenCount xs | otherwise = womenCount xs main = do [input] <- getArgs inText <- readFile input let counter = womenCount (lines inText) print(counter)
decCount :: [[Char]] -> [Int] -> [Int] printResult :: [Int] -> String printResult [d1,d2,d3,d4,d5,d6,d7,d8,d9,d10] = "1901 - 1910: " ++ (show d1) ++ "\n1911 - 1920: " ++ (show d2) ++ "\n1921 - 1930: " ++ (show d3) ++ "\n1931 - 1940: " ++ (show d4) ++ "\n1941 - 1950: " ++ (show d5) ++ "\n1951 - 1960: " ++ (show d6) ++ "\n1961 - 1970: " ++ (show d7) ++ "\n1971 - 1980: " ++ (show d8) ++ "\n1981 - 1990: " ++ (show d9) ++ "\n1991 - 2000: " ++ (show d10)