[Skip To Content]


# 99 bottles in haskell

  1. main = putStrLn ( bottle 99 )
  2. bottle :: Integer -> String
  3. bottle 1 = ( bottle_string 1 ) ++ " on the wall, "
  4. ++ ( bottle_string 1 ) ++ ".\n"
  5. ++ "Go to the store and buy some more, "
  6. ++ ( bottle_string 99 ) ++ " on the wall."
  7. bottle x = ( bottle_string x ) ++ " on the wall, "
  8. ++ ( bottle_string x ) ++ ".\n"
  9. ++ "Take one down and pass it around, "
  10. ++ ( bottle_string ( x - 1 ) ) ++ " on the wall.\n\n"
  11. ++ bottle ( x - 1 )
  12. bottle_string :: Integer -> String
  13. bottle_string 1 = "1 bottle of beer"
  14. bottle_string x = ( show x ) ++ " bottles of beer"

And 99 bottles of beer in Haskell. The code style is a bit more like the usual Haskell style than my last effort, I think.

More about this site...

Last Week’s Top 5 Albums (More »)

  1. Pretty. Odd.Panic at the Disco
  2. BoxerThe National
  3. Du och jag dödenKent
  4. Lovesongs For UnderdogsTanya Donelly
  5. You Are the QuarryMorrissey