diff --git a/Exercise 1/2.hs b/Exercise 1/2.hs new file mode 100644 index 0000000..d5a6ff7 --- /dev/null +++ b/Exercise 1/2.hs @@ -0,0 +1,2 @@ +main :: IO () +main = putStrLn "Hello world" diff --git a/Exercise 1/3.hs b/Exercise 1/3.hs new file mode 100644 index 0000000..1d9f7f3 --- /dev/null +++ b/Exercise 1/3.hs @@ -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" diff --git a/Exercise 1/9.hs b/Exercise 1/9.hs new file mode 100644 index 0000000..d3530e2 --- /dev/null +++ b/Exercise 1/9.hs @@ -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