Add more prax2 programs

This commit is contained in:
Arti Zirk 2017-09-19 17:26:00 +03:00
parent 2db2cfea06
commit 5b4b4271fd
2 changed files with 27 additions and 0 deletions

23
prax2/calc2.hs Normal file
View File

@ -0,0 +1,23 @@
getFloat :: IO Float
getFloat = do
readLn :: IO Float
main :: IO ()
main = do
putStr "Sisesta 1. nr: "
val1 <- getFloat
putStr "Sisesta 2. nr: "
val2 <- getFloat
putStr "Sisesta 3. nr: "
val3 <- getFloat
putStr "Sisesta tehe(+-*/): "
tehe <- getLine
putStr "Tulemus: "
case tehe of
"+" -> putStrLn $ (show(val1 + val2 + val3))
"-" -> putStrLn $ (show(val1 - val2 - val3))
"*" -> putStrLn $ (show(val1 * val2 * val3))
"/" -> putStrLn $ (show(val1 / val2 / val3))
_ -> putStrLn "Ei oska tehet teha"

4
prax2/notBool.hs Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env runghc
notBool :: Bool -> Bool
notBool x = not x