main :: IO () main = do input <- readFile "input" let inPairs = map parseLine . lines $ input let (l1,l2) = unzip inPairs let c = map (\x -> count x l2) l1 print (dot l1 c) toPair [a,b] = (a,b) parseLine = toPair . map (read :: String->Int) . words count x = length . filter (x ==) -- these don't work: --dot = sum . (\(a,b) -> a*b) . zip --dot = sum . zipWith (*) -- these do: --dot l1 l2 = sum $ map (\(a,b) -> a*b) $ zip l1 l2 dot l1 l2 = sum $ zipWith (*) l1 l2 --dot = (sum .) . (zipWith (*))