Advertisement
printesoi

HS2

May 10th, 2014
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Like sscanf(s, "%d")
  2. scanInt :: String -> Int
  3. scanInt = read :: String -> Int
  4.  
  5. -- Parse a string that contains a list of numbers
  6. readInts :: String -> [Int]
  7. readInts line = map scanInt (words line)
  8.  
  9. calculate :: [Int] -> String
  10. calculate xs = show $ sum xs
  11.  
  12. main = do
  13.   line <- getLine
  14.   xs <- readInts line
  15.   putStrLn $ calculate xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement