Skip to content

fixed solution 4 #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: solutions
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Homework03/Solution.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down