Skip to content

Instantly share code, notes, and snippets.

@pao
Created March 15, 2012 17:11
Show Gist options
  • Save pao/2045345 to your computer and use it in GitHub Desktop.
Save pao/2045345 to your computer and use it in GitHub Desktop.
Add numbers in a file (sample problem)
module Total where
import Data.Char
import System.IO
main = do
contents <- readFile "numbers.txt"
print $ add_up contents
add_up :: String -> Double
add_up s = sum $ map read $ filter (not . isWhite) $ lines s
isWhite s = and $ map isSpace s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment