Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- instance Ord Combo where
- compare RoyalFlush RoyalFlush = EQ
- compare RoyalFlush _ = GT
- compare _ RoyalFlush = LT
- compare (StraightFlush x)(StraightFlush y) = compare x y
- compare (StraightFlush _) _ = GT
- compare _ (StraightFlush _) = LT
- compare (FourOfAKind x)(FourOfAKind y) = compare x y
- compare (FourOfAKind _) _ = GT
- compare _ (FourOfAKind _) = LT
- compare (FullHouse x1 x2)(FullHouse y1 y2)
- | x1 == y1 && x2 == y2 = EQ
- | x1 == y1 && x2 > y2 = GT
- | x1 == y1 && x2 < y2 = LT
- | x1 < y1 = LT
- | x1 > y1 = GT
- | otherwise = EQ -- this will nevar happen..
- compare (FullHouse _) _ = GT
- compare _ (FullHouse _) = LT
- compare (Flush x1 x2 x3 x4 x5) (Flush y1 y2 y3 y4 y5) = compare (x1+x2+x3+x4+x5) (y1+y2+y3+y4+y5)
- compare (Flush _ _ _ _ _) _ = GT
- compare _ (Flush _ _ _ _ _) = LT
- compare (Straight x)(Straight y) = compare x y
- compare (Straight _) _ = GT
- compare _ (Straight _) = LT
- compare (ThreeOfAKind x)(ThreeOfAKind y) = compare x y
- compare (ThreeOfAKind _) _ = GT
- compare _ (ThreeOfAKind _) = LT
- compare (TwoPair x1 x2) (TwoPair y1 y2)
- | x1 == y1 && x2 == y2 = EQ
- | x1 == y1 && x2 > y2 = GT
- | x1 == y1 && x2 < y2 = LT
- | x1 < y1 && x2 == y2 = LT
- | x1 < y1 && x2 > y2 = if (y1 - x1) == (x2 - y2)
- then EQ
- else
- if (y1 - x1) > (x2 - y2)
- then LT
- else GT
- | x1 < y1 && x2 < y2 = LT
- | x1 > y1 && x2 == y2 = GT
- | x1 > y1 && x2 > y2 = GT
- | x1 > y1 && x2 < y2 = if (x1 - y1) == (y2 - x2)
- then EQ
- else
- if (x1 - y1) > (y2 - x2)
- then GT
- else LT
- compare (TwoPair _ _) _ = GT
- compare _ (TwoPair _ _) = LT
- compare (OnePair x)(OnePair y) = compare x y
- compare (OnePair _) _ = GT
- compare _ (OnePair _) = LT
- compare (HighCard x)(HighCard y) = compare x y
- -- Als hoogte kaart gelijk is naar de tweede kaart kijken etc?
- instance Eq Combo where
- (==) RoyalFlush RoyalFlush = True
- (==) RoyalFlush _ = False
- (==) (StraightFlush x)(StraightFlush y) = x == y
- (==) (StraightFlush _) _ = False
- (==) (FourOfAKind x)(FourOfAKind y) = x == y
- (==) (FourOfAKind _) _ = False
- (==) (FullHouse x1 x2)(FullHouse y1 y2) = (x1 == y1) && (x2 == y2)
- (==) (FullHouse _ _) _ = False
- (==) (Flush x1 x2 x3 x4 x5) (Flush y1 y2 y3 y4 y5) = (x1 == y1) && (x2 == y2) && (x3 == y3) && (x4 == y4) && (x5 == y5)
- (==) (Flush _ _ _ _ _) _ = False
- (==) (Straight x)(Straight y) = x == y
- (==) (Straight x) _ = False
- (==) (ThreeOfAKind x)(ThreeOfAKind y) = x == y
- (==) (ThreeOfAKind _) _ = False
- (==) (TwoPair x1 x2)(TwoPair y1 y2) = (x1 == y1) && (x2 == y2)
- (==) (TwoPair _ _) _ = False
- (==) (OnePair x)(OnePair y) = x == y
- (==) (OnePair _) _ = False
- (==) (HighCard x)(HighCard y) = x == y
- (/=) x y = not (x == y)
Add Comment
Please, Sign In to add comment