Last active
November 6, 2019 05:46
-
-
Save topher6345/5dcf3b75a2c9f541401e47fc2075ad38 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
module Bottles where | |
import Data.List | |
-- First part of the verse | |
antecedent 1 = "1 bottle of beer on the wall. 1 botle of beer. \n" | |
antecedent 0 = "No more bottles of beer on the wall, no more bottles of beer.\n" | |
antecedent n = (show n) ++ " bottles of beer on the wall. " ++ (show n) ++ " bottles of beer.\n" | |
-- Second part of the verse | |
consequent 0 = "Go to the store and buy some more, 99 bottles of beer on the wall...\n" | |
consequent n = "Take one down, pass it around. " ++ (show (n - 1)) ++ " bottles of beer on the wall!\n" | |
-- Join antecedent and consequent | |
makeLine n = (antecedent n) ++ (consequent n) | |
e = cycle [99, 98..0] | |
-- Combine index with lyrics | |
f = map (\x -> makeLine x) | |
-- How many verses we want to sing | |
n = 120 | |
all = take n e | |
main = do | |
putStrLn $ intercalate "" $ f Bottles.all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment