ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

Haskell need help, please
Posted by Konstantin 20 Feb 2013 16:16
I'm only start to learn Haskell.
I'm confused with std function and IO.

My solution (does not work):
main = do
   a <- getLine
   let b = sum map read words a // <- I try to use this functions
   putStrLn (show b)

let b = words a // work, but
let b = sum map (read::Int) words a //does not work

Where I wrong?
Re: Haskell need help, please
Posted by Vasily645 7 Mar 2013 00:42
try this
let b str = sum (map (read :: String -> Int) (words str))
or this
let b str = sum (map read (words str)) :: Int
related info:
http://www.haskell.org/haskellwiki/Type_inference
http://www.haskell.org/tutorial/classes.html
Re: Haskell need help, please
Posted by Konstantin 7 Mar 2013 09:24
Thank you very much :)