Reputation: 627
I am a new one for Haskell. I have a question here. I can do the task by guards like this
task2 x "Celsius"
| x>=20 = "It is Hot"
| x<= (-5) = "It is very cold"
| x<=10 = "It is cold"
| x<20 = "It is warm"
how to use case function to do this task?
like
case x "Celsius" = case x of x>=20, but it is not work.
Upvotes: 0
Views: 402
Reputation: 29110
You can put guards into a case
expression like this:
case some_expression of
x | x>=20 -> "It is Hot"
| x<= (-5) -> "It is very cold"
....
Upvotes: 3