Created
November 23, 2015 12:44
-
-
Save chuck0523/47832dfabc9925d5564e 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
main = do | |
putStrLn "挨拶といえば?" | |
greeting <- getLine | |
answerToGreeting greeting | |
putStrLn "なんか数字を。" | |
num <- getLine | |
putStrLn (checkNum num) | |
-- 純粋でない関数内の`if` | |
-- `then`, `else`のあとに`do`をつける | |
answerToGreeting greeting = do | |
if greeting == "hi" | |
then do | |
putStrLn "You are using English" | |
else do | |
putStrLn "日本語ですね" | |
-- 純粋な関数内の`if` | |
-- `then`, `else`のあとに`do`をつけない | |
checkNum num = | |
if num == "0" | |
then "ゼロです" | |
else "ゼロではないです" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment