A+B: Difference between revisions

98 bytes removed ,  14 years ago
m (→‎{{header|Ruby}}: demonstrate the "inject(&:symbol)" syntax)
Line 103:
</pre>
 
<lang haskell>import Control.Monad
=={{header|Haskell}}==
sum' :: [Char] -> Int
{{incorrect|Haskell|It does not work with numbers separated by a space; it only works with numbers on separate lines.}}
sum' = sum . map read . words
<lang haskell>import Control.Monad
 
main = getLine >>= (\xs -> putStrLn $ show $ sum' xs)
main = liftM2 (+) readLn readLn >>= print</lang>
</lang>
 
=={{header|Java}}==
Anonymous user