Skip to content

Instantly share code, notes, and snippets.

@lgastako lgastako/Beer.hs

Created Jan 25, 2020
Embed
What would you like to do?
main :: IO ()
main = mapM_ putStrLn beerLines
where
beerLines = concatMap genLines [99, 98..1]
genLines n =
[ firstLine n
, "Take one down, pass it around, " ++ suffix n
]
firstLine 1 = "1 bottle of beer on the wall, 1 bottle of beer."
firstLine n = show n ++ " bottles of beer on the wall, "
++ show n ++ " bottles of beer."
suffix 1 = "no more beer on the wall!"
suffix 2 = "1 bottle of beer on the wall"
suffix n = show (n - 1) ++ " bottles of beer on the wall"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.