From 0287d2da77eed37ecd6bbd307f70863ee89ae830 Mon Sep 17 00:00:00 2001 From: Jan Chrtiansky Date: Sun, 15 Sep 2024 16:07:30 +0200 Subject: [PATCH] fixed solution 4 --- Homework03/Solution.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Homework03/Solution.hs b/Homework03/Solution.hs index b7eec49a..17aec8ce 100644 --- a/Homework03/Solution.hs +++ b/Homework03/Solution.hs @@ -37,11 +37,10 @@ checkConsumption consumption time maxC guardsAndIf :: Double -> Double -> String guardsAndIf a b - | a < 0 && b < 0 = if (a < b) then show (b / a) else show (a / b) - | a > b = if a /= 0 then show (a/b) else "a is larger but 0" - | a < b = if b /= 0 then show (b/a) else "b is larger but 0" - | otherwise = if a /= 0 then "1" else "a and b are both 0" - + | a < 0 && b < 0 = if a > b then show (a / b) else show (b / a) + | a > 0 && b > 0 = if a < b then show (a / b) else show (b / a) + | a /= b = if a /= 0 then show (b / a) else show (a / b) + | otherwise = "a and b are both 0" -- Question 5 -- Write a function that takes in two numbers and calculates the sum of square roots for the product and quotient