I am trying to pick up Haskell!
But I feel like my code is a bit painful to write and read.
Do you have any pointers on how to improve its readability / style?
main = do contents <- fmap tail . fmap lines . readFile $ "testInput" let input = map pair_to_tuple .(map (map read)) . map words $ contents :: [(Int,Int)] let result = map (uncurry waffles) $ input let decorated_result = ["Case #" ++ show i ++ ": " ++ show s | (i,s) <- zip [1..length result] result] writeFile "output.txt" $ unlines $ decorated_result waffles row col = (row - 1)*(col - 1) pair_to_tuple [a,b] = (a,b)
This script reads a file whose first line is a title, then every line is a couple of numbers. Then it drops the first line, and processes every pair of numbers using the function
waffles, then it writes it back to an output file.