Haskell: how to use case function

Xie

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.

GS - Apologise to Monica

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"
      ....

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to use the argument of a function in a high order function in Haskell

From Dev

Haskell - Lenses, use of 'to' function

From Dev

How to use multiple 'commands' in the same function in Haskell

From Dev

A case of general function transformation in Haskell

From Dev

PostgreSQL: How to use SELECT statement within CASE expression in function?

From Dev

How to use (.) in Haskell

From Dev

Haskell - How to use a function that returns 'Maybe Int' as an argument to another function?

From Dev

use ord function in haskell is not is scope

From Dev

How to use the "Of" lenses? (Haskell)

From Dev

How to analyse a function in Haskell?

From Dev

In Haskell, how do you use 'head' without creating a separate function?

From Dev

How to properly use Haskell's `parseTimeM` function?

From Dev

What is a practical use case for this function?

From Dev

How to use Apply function in a column dependent case?

From Dev

How to repeat a function in this case? Haskell

From Dev

How to wrap function in haskell?

From Dev

Haskell: How to use random integer from randomRIO in a function that returns a boolean

From Dev

How to understand the function "(.)(.)" in Haskell

From Dev

Intended use of case `this` in anonymous function?

From Dev

PostgreSQL: How to use SELECT statement within CASE expression in function?

From Dev

How to use (.) in Haskell

From Dev

change the function to use recursion in Haskell

From Dev

haskell case that calls a function

From Dev

How to properly use Haskell's `parseTimeM` function?

From Dev

What is a practical use case for this function?

From Dev

How to use the MAX and Case function over three tables?

From Dev

How to wrap function in haskell?

From Dev

scala- dataset- how to use a function on two case classes?

From Dev

How to use submit value in Controller switch case function?

Related Related

  1. 1

    How to use the argument of a function in a high order function in Haskell

  2. 2

    Haskell - Lenses, use of 'to' function

  3. 3

    How to use multiple 'commands' in the same function in Haskell

  4. 4

    A case of general function transformation in Haskell

  5. 5

    PostgreSQL: How to use SELECT statement within CASE expression in function?

  6. 6

    How to use (.) in Haskell

  7. 7

    Haskell - How to use a function that returns 'Maybe Int' as an argument to another function?

  8. 8

    use ord function in haskell is not is scope

  9. 9

    How to use the "Of" lenses? (Haskell)

  10. 10

    How to analyse a function in Haskell?

  11. 11

    In Haskell, how do you use 'head' without creating a separate function?

  12. 12

    How to properly use Haskell's `parseTimeM` function?

  13. 13

    What is a practical use case for this function?

  14. 14

    How to use Apply function in a column dependent case?

  15. 15

    How to repeat a function in this case? Haskell

  16. 16

    How to wrap function in haskell?

  17. 17

    Haskell: How to use random integer from randomRIO in a function that returns a boolean

  18. 18

    How to understand the function "(.)(.)" in Haskell

  19. 19

    Intended use of case `this` in anonymous function?

  20. 20

    PostgreSQL: How to use SELECT statement within CASE expression in function?

  21. 21

    How to use (.) in Haskell

  22. 22

    change the function to use recursion in Haskell

  23. 23

    haskell case that calls a function

  24. 24

    How to properly use Haskell's `parseTimeM` function?

  25. 25

    What is a practical use case for this function?

  26. 26

    How to use the MAX and Case function over three tables?

  27. 27

    How to wrap function in haskell?

  28. 28

    scala- dataset- how to use a function on two case classes?

  29. 29

    How to use submit value in Controller switch case function?

HotTag

Archive