SHARE
TWEET

Untitled

a guest Jan 21st, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. data Values = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King | Ace deriving (Show)
  3.  
  4. data Suits = Spades | Hearts | Diamonds | Clubs deriving (Show)
  5.  
  6. type Cards = (Values, Suits)
  7.  
  8. greaterCard :: Cards -> Cards -> Bool
  9. greaterCard (suits1, value1) (suits2, value2)
  10.       | convertValue value1 > convertValue value2 == True
  11.       | convertValue value1 == convertValue value2 = if convertSuits suits1 > convertSuits suits2 then True else False  
  12.       | Otherwise False
  13.      
  14. convertValue :: Values -> Int
  15. convertValue Two = 2
  16. convertValue Three = 3
  17. convertValue Four = 4
  18. convertValue Five = 5
  19. convertValue Six = 6
  20. convertValue Seven = 7
  21. convertValue Eight = 8
  22. convertValue Nine = 9
  23. convertValue Ten = 10
  24. convertValue Jack = 11
  25. convertValue Queen = 12
  26. convertValue King = 13
  27. convertValue Ace = 14
  28.  
  29. convertSuits :: Suits -> Int
  30. convertSuits Spades = 4
  31. convertSuits Hearts = 3
  32. convertSuits Diamonds = 2
  33. convertSuits Clubs = 1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top