Browse Source

Add more prax2 programs

master
Arti Zirk 2 years ago
parent
commit
5b4b4271fd
2 changed files with 27 additions and 0 deletions
  1. +23
    -0
      prax2/calc2.hs
  2. +4
    -0
      prax2/notBool.hs

+ 23
- 0
prax2/calc2.hs 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
- 0
prax2/notBool.hs View File

@@ -0,0 +1,4 @@
#!/usr/bin/env runghc

notBool :: Bool -> Bool
notBool x = not x

Loading…
Cancel
Save