Created
March 4, 2014 12:52
-
-
Save Nucleareal/9345929 to your computer and use it in GitHub Desktop.
99 Bottles of Beer on Haskell
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
| import Control.Monad | |
| show' :: Int -> String | |
| show' x | |
| | x == 0 = "no more bottles" | |
| | x == 1 = "1 bottle" | |
| | otherwise = show x ++ " bottles" | |
| main = forM [99,98..0] (\x -> putStrLn $ | |
| if x == 0 | |
| then | |
| "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall." | |
| else | |
| show' x ++ " of beer on the wall, " ++ show' x ++ " of beer.\nTake one down and pass it around, " ++ show' (x-1) ++ "of beer on the wall.\n" ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment