Last active
August 29, 2015 14:16
-
-
Save mdippery/924d024444cad0447d8a to your computer and use it in GitHub Desktop.
Calculates Chinese zodiac sign for a given year
This file contains 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
import System.Console.GetOpt (ArgOrder(..), getOpt) | |
import System.Environment (getArgs) | |
offset = (flip mod) 12 | |
animal 4 = "Rat" | |
animal 5 = "Ox" | |
animal 6 = "Tiger" | |
animal 7 = "Rabbit" | |
animal 8 = "Dragon" | |
animal 9 = "Snake" | |
animal 10 = "Horse" | |
animal 11 = "Sheep" | |
animal 0 = "Monkey" | |
animal 1 = "Rooster" | |
animal 2 = "Dog" | |
animal 3 = "Pig" | |
parseArgs = getOpt RequireOrder [] | |
main = do | |
argv <- getArgs | |
let year = case parseArgs argv of | |
([], year:_, []) -> read year :: Int | |
putStrLn $ animal $ offset year |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment