Programmers, in their continual search for popular acceptance, have made writing a program to generate the
lyrics of 99 Bottles of Beer into somewhat of an advanced
“Hello World” exercise. I did it today in Clojure and it took me about 5 minutes. There’s a repository of programs written in 1270 programming languages.
; 99 bottles of beer in Clojure; Kanwei Li, 2009(defn inflect-bottle[time](cond (= time1)"1 bottle of beer"(= time0)"no more bottles of beer":else(str time" bottles of beer")))(defn sing[time](if (= time0)(println (str "No more bottles of beer on the wall, no more bottles of beer.\n""Go to the store and buy some more, 99 bottles of beer on the wall."))(let [inflected(inflect-bottletime)next-time(- time1)](println (str inflected" on the wall, "inflected".\nTake one down and pass it around, "(inflect-bottlenext-time)" on the wall.\n"))(recurnext-time))))(sing99)
Posted on
About
Kanwei Li
I don't always look good in photos. But when I do, I make sure to post it on the internet.
I game on a Mac and program on a PC.
I write PHP for fun.
I once aced the MCAT... and turned down medical school.