Created
August 16, 2014 23:08
-
-
Save dskecse/3449a3498a4b11c63193 to your computer and use it in GitHub Desktop.
Implementations of a function that converts a String to an Action
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
convertStringToAction :: String -> Action | |
convertStringToAction str = case str of | |
"Look" -> Look | |
"New" -> New | |
otherwise -> Quit | |
-- guards (охранные выражения) | |
convertStringToAction' :: String -> Action | |
convertStringToAction' str | str == "Look" = Look | |
| str == "New" = New | |
| otherwise = Quit | |
-- pattern matching (сопоставление с образцом) | |
convertStringToAction'' :: String -> Action | |
convertStringToAction'' "Look" = Look | |
convertStringToAction'' "New" = New | |
convertStringToAction'' _ = Quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment