Skip to content

Instantly share code, notes, and snippets.

@lgastako
Created January 25, 2020 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgastako/2e7dfd6b1118bb408ff114a4be46eac9 to your computer and use it in GitHub Desktop.
Save lgastako/2e7dfd6b1118bb408ff114a4be46eac9 to your computer and use it in GitHub Desktop.
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