Guest User

Untitled

a guest
Jan 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. instance Ord Combo where
  2.     compare RoyalFlush RoyalFlush               = EQ
  3.     compare RoyalFlush _                        = GT
  4.     compare _ RoyalFlush                        = LT
  5.     compare (StraightFlush x)(StraightFlush y)  = compare x y
  6.     compare (StraightFlush _) _                 = GT
  7.     compare _ (StraightFlush _)                 = LT
  8.     compare (FourOfAKind x)(FourOfAKind y)      = compare x y
  9.     compare (FourOfAKind _) _                   = GT
  10.     compare _ (FourOfAKind _)                   = LT
  11.  
  12.     compare (FullHouse x1 x2)(FullHouse y1 y2)
  13.         | x1 == y1 && x2 == y2 = EQ
  14.         | x1 == y1 && x2 >  y2 = GT
  15.         | x1 == y1 && x2 <  y2 = LT
  16.         | x1 <  y1             = LT
  17.         | x1 >  y1             = GT
  18.         | otherwise = EQ -- this will nevar happen..
  19.     compare (FullHouse _) _                   = GT
  20.     compare _ (FullHouse _)                   = LT
  21.  
  22.     compare (Flush x1 x2 x3 x4 x5) (Flush y1 y2 y3 y4 y5) = compare (x1+x2+x3+x4+x5) (y1+y2+y3+y4+y5)
  23.     compare (Flush _ _ _ _ _) _                 = GT
  24.     compare _ (Flush _ _ _ _ _)                 = LT
  25.     compare (Straight x)(Straight y)            = compare x y
  26.     compare (Straight _) _                      = GT
  27.     compare _ (Straight _)                      = LT
  28.     compare (ThreeOfAKind x)(ThreeOfAKind y)    = compare x y
  29.     compare (ThreeOfAKind _) _                  = GT
  30.     compare _ (ThreeOfAKind _)                  = LT
  31.     compare (TwoPair x1 x2) (TwoPair y1 y2)
  32.         | x1 == y1 && x2 == y2 = EQ
  33.         | x1 == y1 && x2 >  y2 = GT
  34.         | x1 == y1 && x2 <  y2 = LT
  35.         | x1 <  y1 && x2 == y2 = LT
  36.         | x1 <  y1 && x2 >  y2 = if (y1 - x1) == (x2 - y2)
  37.                                     then EQ
  38.                                     else
  39.                                         if (y1 - x1) > (x2 - y2)
  40.                                             then LT
  41.                                             else GT
  42.         | x1 <  y1 && x2 <  y2 = LT
  43.         | x1 >  y1 && x2 == y2 = GT
  44.         | x1 >  y1 && x2 >  y2 = GT
  45.         | x1 >  y1 && x2 <  y2 = if (x1 - y1) == (y2 - x2)
  46.                                     then EQ
  47.                                     else
  48.                                         if (x1 - y1) > (y2 - x2)
  49.                                             then GT
  50.                                             else LT
  51.     compare (TwoPair _ _) _             = GT
  52.     compare _ (TwoPair _ _)             = LT
  53.     compare (OnePair x)(OnePair y)      = compare x y
  54.     compare (OnePair _) _               = GT
  55.     compare _ (OnePair _)               = LT
  56.     compare (HighCard x)(HighCard y)    = compare x y
  57. -- Als hoogte kaart gelijk is naar de tweede kaart kijken etc?  
  58.    
  59. instance Eq Combo where
  60.     (==) RoyalFlush RoyalFlush                          = True
  61.     (==) RoyalFlush _                                   = False
  62.     (==) (StraightFlush x)(StraightFlush y)             = x == y
  63.     (==) (StraightFlush _) _                            = False
  64.     (==) (FourOfAKind x)(FourOfAKind y)                 = x == y
  65.     (==) (FourOfAKind _) _                              = False
  66.     (==) (FullHouse x1 x2)(FullHouse y1 y2)             = (x1 == y1) && (x2 == y2)
  67.     (==) (FullHouse _ _) _                              = False
  68.     (==) (Flush x1 x2 x3 x4 x5) (Flush y1 y2 y3 y4 y5)  = (x1 == y1) && (x2 == y2) && (x3 == y3) && (x4 == y4) && (x5 == y5)
  69.     (==) (Flush _ _ _ _ _) _                            = False
  70.     (==) (Straight x)(Straight y)                       = x == y
  71.     (==) (Straight x) _                                 = False
  72.     (==) (ThreeOfAKind x)(ThreeOfAKind y)               = x == y
  73.     (==) (ThreeOfAKind _) _                             = False
  74.     (==) (TwoPair x1 x2)(TwoPair y1 y2)                 = (x1 == y1) && (x2 == y2)
  75.     (==) (TwoPair _ _) _                                = False
  76.     (==) (OnePair x)(OnePair y)                         = x == y
  77.     (==) (OnePair _) _                                  = False
  78.     (==) (HighCard x)(HighCard y)                       = x == y
  79.     (/=) x y                                            = not (x == y)
Add Comment
Please, Sign In to add comment