Add tasks

This commit is contained in:
Oystein Kristoffer Tveit 2020-10-05 12:13:59 +02:00
parent e273e2a7d9
commit 697f4ab914
3 changed files with 26 additions and 0 deletions

2
Exercise 1/2.hs Normal file
View File

@ -0,0 +1,2 @@
main :: IO ()
main = putStrLn "Hello world"

10
Exercise 1/3.hs Normal file
View File

@ -0,0 +1,10 @@
main :: IO ()
main = do
putStrLn $ show $ 1 + 2 * (3+4) + 4/2 - 1
let minutter = 355 :: Int
let timer = minutter `div` 60
let minutterIgjen = minutter `mod` 60
putStrLn $ show $ show minutter ++ " minutter blir " ++ show timer ++ " timer og " ++ show minutterIgjen ++ " minutter"

14
Exercise 1/9.hs Normal file
View File

@ -0,0 +1,14 @@
main :: IO ()
main = do
input <- promptLine "Skriv inn h: "
let h = read input :: Double
putStrLn $ show $ tetraederVolum h
promptLine :: String -> IO String
promptLine prompt = do
putStr prompt
getLine
tetraederVolum :: Double -> Double
tetraederVolum h = sqrt 2 * a / 12
where a = 3 / sqrt 6 * h