Created
June 23, 2015 16:06
-
-
Save gfixler/7c30ce9a262094d78265 to your computer and use it in GitHub Desktop.
99 bottles
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
bottles :: Int -> String | |
bottles x | x == 0 = "No more bottles" | |
| x == 1 = "1 more bottle" | |
| x < 13 = show x ++ " more bottles" | |
| otherwise = show x ++ " bottles" | |
verse :: Int -> String | |
verse x = line1 ++ "\n" ++ line2 ++ "\n\n" | |
where line1 = bottles x ++ obotw ++ " " ++ bottles x ++ ob | |
line2 = todpia ++ bottles (x-1) ++ obotw | |
obotw = " of beer on the wall." | |
ob = " of beer." | |
todpia = "Take one down, pass it around. " | |
main :: IO () | |
main = mapM_ putStr $ map verse [99,98..1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment