From 5b4b4271fda81d7faa0be30107edfe72062d7523 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Tue, 19 Sep 2017 17:26:00 +0300 Subject: [PATCH] Add more prax2 programs --- prax2/calc2.hs | 23 +++++++++++++++++++++++ prax2/notBool.hs | 4 ++++ 2 files changed, 27 insertions(+) create mode 100644 prax2/calc2.hs create mode 100644 prax2/notBool.hs diff --git a/prax2/calc2.hs b/prax2/calc2.hs new file mode 100644 index 0000000..961ac4e --- /dev/null +++ b/prax2/calc2.hs @@ -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" diff --git a/prax2/notBool.hs b/prax2/notBool.hs new file mode 100644 index 0000000..c5c7a9c --- /dev/null +++ b/prax2/notBool.hs @@ -0,0 +1,4 @@ +#!/usr/bin/env runghc + +notBool :: Bool -> Bool +notBool x = not x