次の方法で共有


99 Bottles Of Beer

Many years ago (1994) programmer, and my geek idol, Tim Robinson compiled a list of ways to output the lyrics to the song 99 Bottles of Beer. It started with someone posting to a mailing list the entire lyrics to the song and then someone else replied with a Basic version of the song:

10 REM BASIC Version of 99 Bottles of beer
20 FOR X=100 TO 1 STEP -1
30 PRINT X;"Bottle(s) of beer on the wall,";X;"bottle(s) of beer"
40 PRINT "Take one down and pass it around,"
50 PRINT X-1;"bottle(s) of beer on the wall"
60 NEXT

Tim posted a C++ version and it grew from there to hundreds of versions. Unfortunately Tim's web site (and Tim) disappeared from the 'net and all was lost for a few years. Now, Oliver Schade has posted the entire collection and then some on a web site: https://www.99-bottles-of-beer.net.

One of my contributions was Modula-2:

MODULE BottlesOfBeer;

FROM InOut IMPORT WriteCard, WriteString, WriteLn;

CONST
BOTTLES = 99;
VAR
counter : CARDINAL;
BEGIN
counter := BOTTLES;
REPEAT
WriteCard( counter,2 );
WriteString(" bottles of beer on the wall, ");
WriteCard( counter,2 );
WriteString(" bottles of beer."); WriteLn;
WriteString(" Take one down, and pass it around, ");
DEC( counter );
WriteCard( counter,2 );
WriteString(" bottles of beer on the wall."); WriteLn;
UNTIL ( counter = 1 );
WriteString("1 bottle of beer on the wall, 1 bottle of beer"); WriteLn;
WriteString("Take it down and pass it around, ");
WriteString("No more bottles of beer on the wall."); WriteLn;

END BottlesOfBeer.

What I enjoy about this catalog is that people tried to incorporate features from the language. Along with the usual cast of languages like SQL, C#, and various C++ versions, some clever languages were posted. Here are some of my favorites:

SmallTalk

 99 to: 1 by: -1 do: [ :i |
 i print. ' bottles of beer on the wall, ' print.
 i print. ' bottles of beer. ' print.
 'take one down, pass it around, ' print.
 (i-1) print. ' bottles of beer on the wall, ' print.
]

Meta HTML

 <html>
<head> <title> 99 Bottles of Beer: The Compleat Lyrics </title> </head>
<body>
;;;
;;; The actual source code to The Compleat Lyrics.
<defsubst plural whitespace=delete>
  <if <not <eq %0 1>> s>
</defsubst>
<set-var beers=99>
<while <gt beers 0>>
  <get-var beers> bottle<plural beers> of beer on the wall, <br>
  <get-var beers> bottle<plural beers> of beer, <br>
  You take one down, pass it around, <br>
  <decrement beers>
  <get-var beers> bottle<plural beers> of beer on the wall.
  <p>
</while>
No more bottles of beer on the wall, <br>
No more bottles of beer, <br>
Go to the store, and buy some more, <br>
<form method=GET action="<get-var mhtml::current-url>">
  <input type="submit" name="button" value="99 Bottles of beer on the wall">
</form>
</body>
</html>

Perl for Signature

 #!/usr/bin/perl -iake_one_down_pass_it_around:_bottles_of_beer:_on_the_wall:99
for(($t,$a,$b,$i)=split/:/,$^I;$i;print){$_="-$i$a$b,-$i$a,-T$t,-".--$i."$a$b
";s/(-1_.*?e)s/$1/g;y/_-/ \n/}#     by Randolph Chung and Joey Hess

POV Ray

 POV-Ray is a ray-tracing program.
// povray 3 file for the 99 bottles of beer ...
#declare S1 = " bottles"
#declare L1 = " of beer on the wall,\n"
#declare L2 = " of beer.\n"
#declare L3 = "Take one down and pass it around,\n"
#declare L4 = " of beer on the wall.\n\n"
#declare Beer = 99
#declare S2 = concat(str(Beer,0,0),S1)
#render "\n"
#while (Beer > 0)
  #render concat(S2,L1)
  #render concat(S2,L2)
  #render L3
  #declare Beer = Beer - 1
  #if (Beer = 1)
    #declare S2 = "1 bottle"
  #else
    #if (Beer = 0)
      #declare S2 = "No more bottles"
    #else
      #declare S2 = concat(str(Beer,0,0),S1)
    #end
  #end
  #render concat(S2,L4)
#end
sphere { 0, 1 pigment { colour rgb <1,0,0> } }
light_source { x*2, colour rgb 1 }
camera {
  perspective
  location x*2
  look_at 0
}

There are also some unmentionables like this one and this one. 621 versions so far. One glaring omission is Managed C++ [looks over at Yves Dolce]. I also wonder whatever happened to Tim Robinson. He was the brains behind Excalibur BBS which was a Windows based BBS that served up screens with meta-driven GUI. Instead of writing classic BBS doors you would write DLL add-in's. It was unfortunately timed to come out just as the WWW was emerging but the software was very cool nonetheless.

Comments