Basic I/O
Here is the most classic program ever
:)
main = do
print(“Hello Word”)
If we want to get input in Haskell we
can use getline function for strings,integers or other basic input
data. For example :
main= do
putStrLn "enter age"
age <- getLine
putStrLn("Hello " ++ age ++
" boy")
Let do some fun thing with simple ı/o
and some condition situations :)
main= do
putStrLn "enter age"
age <- getLine
if read(age) > 50
then do print("You are too old
man")
else
do print("Yeah men you have a
lot of time for Haskell !")
In line 2 we enter the value of the
age.line 3 take the argument and equalize the value of the age
variable. In line 4 with read function we can compare a string and a
integer because Getline function get string and read function change
it.then line in line 4 if do the condition things and “then do”
parts is returning part.
Hiç yorum yok:
Yorum Gönder