Created
May 22, 2012 01:17
-
-
Save lambda-fairy/2765894 to your computer and use it in GitHub Desktop.
Soctopus Prediction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | <http://ncss.edu.au/challenge/ncss_challenge_2012.pdf> | |
| class Semigroup a where | |
| (<>) :: a -> a -> a | |
| data Result = Team String | Draw Int | |
| resultLength :: Result -> Int | |
| resultLength (Team name) = length name | |
| resultLength (Draw lgth) = lgth | |
| instance Semigroup Result where | |
| a <> b | |
| | x < y = b | |
| | x > y = a | |
| | otherwise = Draw x | |
| where | |
| x = resultLength a | |
| y = resultLength b | |
| showResult :: Result -> String | |
| showResult (Team name) = name | |
| showResult (Draw _) = "Draw" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment