Created
June 18, 2017 13:50
-
-
Save furu/57e8abe905ef93bdedf5886f85c52a5d to your computer and use it in GitHub Desktop.
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
main = undefined | |
-- | 商品を買えるか調べる関数 | |
-- | |
-- 「所持金 (money)」と「商品の値段 (price)」を渡すと、 | |
-- 購入可能なら True、購入不可能なら False を返す。 | |
-- | |
-- >>> canBuy 100 300 | |
-- False | |
-- | |
-- >>> canBuy 300 100 | |
-- True | |
-- | |
-- >>> canBuy 300 300 | |
-- True | |
-- | |
-- >>> canBuy 100000 83495 | |
-- True | |
-- | |
-- >>> canBuy 123456 999999 | |
-- False | |
canBuy :: Int -> Int -> Bool | |
canBuy money price | |
| money >= price = True | |
| otherwise = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment