99 bottles of beer
投稿者 okkez
なんとなく思い立って Haskell で書いてみた。 FizzBuzz と余り変わらない感じですね。
99 bottles of beermain = putStr $ unlines [sing x | x <- reverse [1..1000]] sing :: Int -> String sing n = unlines [ (show n) ++ bottle n ++ " of beer on the wall" ,(show n) ++ bottle n ++ " of beer" ,"Take one down and pass it around" ,(show $ n - 1) ++ (bottle $ n - 1) ++ " of beer on the wall"] bottle :: Int -> String bottle n | n == 1 = " Bottle" | otherwise = " Bottles"


