Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell print string without newline

When I use this code it's print newline after result. How I can don't write newline?

import System.IO

main :: IO ()
main  = do
        a <- getLine
        b <- getLine
        let aa = read a :: Int
        let bb = read b :: Int
        let cc = aa + bb
        print cc
like image 697
user2401036 Avatar asked May 20 '13 08:05

user2401036


Video Answer


1 Answers

print is defined as putStrLn . show, the fix is to use putStr . show $ cc.

like image 152
huon Avatar answered Oct 12 '22 06:10

huon