Created
July 12, 2016 23:37
-
-
Save joshvera/606ea0a3c10125c75febf879173c378b to your computer and use it in GitHub Desktop.
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
parseRank :: String -> Rank | |
parseRank string = case string of | |
"clubs" -> Club | |
"diamonds" -> Diamond | |
"spades" -> Spade | |
"hearts" -> Heart | |
_ -> Heart | |
parseNumber :: String -> Number | |
parseNumber string = case string of | |
"ace" -> Ace | |
"two" -> Two | |
"three" -> Three | |
"four" -> Four | |
"five" -> Five | |
"six" -> Six | |
"seven" -> Seven | |
"eight" -> Eight | |
"nine" -> Nine | |
"ten" -> Ten | |
"jack" -> Jack | |
"queen" -> Queen | |
"king" -> King | |
parseString :: String -> Card | |
parseString string = case words string of | |
[number, theWordOf, rank] -> Card number (parseRank rank) | |
_ -> Card Ace Heart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment