99_bottles_of_beer
Mahayana: Zakah: & Language Structures Lingo style

Lingo is Macromedia's Director scripting language.
-- Lingo version of 99 Bottles of Beer


on BottlesOfNABeer
-- This handler outputs to the message window.

set maxBottles to 99

repeat with bottles = maxBottles down to 1
set bottleString to WhichString(bottles)
put bottleString & " of beer on the wall, " & bottleString & " of beer."
put "Take one down, pass it around,"
put WhichString(bottles - 1) & " of beer on the wall."
put RETURN
end repeat

put "No bottles of beer on the wall, no bottles of beer."
put "Go to the store and buy some more."
put maxBottles & " bottles of beer on the wall."

end BottlesOfNABeer


on WhichString bottles

if bottles 1 then
return bottles & " bottles"
else if bottles = 1 then
return "1 bottle"
else
return "No more bottles"
end if

end WhichString
020107
...
Mahayana: Zakah: & Language Structures six lines of BASIC:

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
020107
...
Mahayana: Zakah: & Language Structures ## 99.bb v1.2
# some handy macros

/nprint {" " add print} def
/space {" " print} def
/dec {dup get 1 sub def} def
/class-define {{get invoke} bind pop-dict} def

# i will use the bobo object protocol! it is cool.

/new-bar {
13 /bar-dict create-dict

/count 0 def
/lyric-type "I'm a computer, I can't decide what to say," def

/set-count {/count exch def} def
/set-lyric-type {/lyric-type exch def} def

# proper grammar counts

/bottle-thing {
/i exch rdef

i 1 eq {
i " bottle" add print
} {
i " bottles" add print
} if-else
} def

# and, the meat of it!

/beer-lyrics {
/i exch rdef

i bottle-thing " of beer on the wall," nprint
i bottle-thing " of beer!" nprint
lyric-type nprint
i 1 sub bottle-thing " of beer on the wall." nprint space
} def

/final-lyrics {
"0 bottles of beer on the wall," nprint
"0 bottles of beer." nprint
"Go into town, buy a new round," nprint
"Get some more bottles of beer on the wall!" nprint
} def

/consume {
count {
count beer-lyrics
/count dec
} {
final-lyrics
} if-else
} def

class-define
} def

/song {
/lyric-type exch rdef
/count exch rdef

/bar new-bar rdef

count /set-count bar
lyric-type /set-lyric-type bar

count 1 add {/consume bar} loop
} def

/messy "If one of those bottles should happen to fall," def
/thirsty "Take one down, pass it around," def

99 thirsty song
020107
...
Mahayana: Zakah: & Language Structures Sendmail

Sendmail is used by mail systems for routing and controlling e-mail delivery.

# Save this to /tmp/foo.bar
# echo '49 9 9' | /usr/lib/sendmail -bt -d21 -C/tmp/foo.bar
# Sorry, Smail is too brain dead to run this. Use sendmail instead.

DH"take one down, pass it around,"
DG"bottles of beer"
DF"$G on the wall."
DE"$G on the wall,"
DN"No beer left."

S45
R$- 2 $* foo bar $1 1 $F
R$- 3 $* $1 2 $F
R$- 4 $* $1 3 $F
R$- 5 $* $1 4 $F
R$- 6 $* $1 5 $F
R$- 7 $* $1 6 $F
R$- 8 $* $1 7 $F
R$- 9 $* $1 8 $F
R9 0 $* 8 9 $F
R8 0 $* 7 9 $F
R7 0 $* 6 9 $F
R6 0 $* 5 9 $F
R5 0 $* 4 9 $F
R4 0 $* 3 9 $F
R3 0 $* 2 9 $F
R2 0 $* 1 9 $F
R1 0 $* 0 9 $F
R$- 1 $* $1 0 $F
Rfoo bar $- 1 $F $1 1 $F
R0 0 $* $N

S47
R$- $- $E $1 $2 $G,

S48
R$- $- $47 $1 $2 $E
R$- $- $G, $45 $1 $2 $H
R$- $- $F $1 $2
R$N *burp*

S49
R$- $- $48 $1 $2
020107
...
Mahayana: Zakah: & Language Structures (* Pascal version of 99 Bottles of beer *)
program BottlesOfBeers(input, output);
var
bottles: integer;
begin
bottles := 99;
repeat
WriteLn(bottles, ' bottles of beer on the wall, ',
bottles, ' bottles of beer.');
Write('Take one down, pass it around, ');
bottles := bottles-1;
WriteLn(bottles, ' bottles of beer on the wall.');
until (bottles = 1);
WriteLn('1 bottle of beer on the wall, one bottle of beer.');
WriteLn('Take one down, pass it around,'
' no more bottles of beer on the wall')
end.
020107
...
Mahayana: Zakah: & Language Structures The scripting language used for Microsoft Word
Sub MAIN
REM "99 bottles of beer on the wall"
REM Microsoft Word WordBasic macro language version
FileNew
beer$ = "99"
bottle$ = " bottles "
For count = 99 To 1 Step - 1
Insert beer$ + bottle$ + "of beer on the wall,"
InsertPara
Insert beer$ + bottle$ + "of beer,"
InsertPara
Insert "Take "
If count 1 Then
Insert "one"
Else
Insert "it"
End If
Insert " down, pass it around,"
InsertPara
If count 1 Then
beer$ = Str$(count - 1)
beer$ = Right$(beer$, Len(beer$) - 1)
If count = 2 Then bottle$ = " bottle "
Insert beer$ + bottle$ + "of beer on the wall."
InsertPara
Else
Insert "No more bottles of beer on the wall."
End If
InsertPara
Next
End Sub
020107
...
Mahayana: Zakah: & Language Structures COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID.BOTTLES_OF_BEER.
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. VAX.
OBJECT-COMPUTER. VAX.
*
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUTPUT-FILE
ASSIGN TO BEERS_ON_THE_WALL.
*
DATA DIVISION.
FILE SECTION.
FD OUTPUT-FILE
LABEL RECORDS ARE OMITTED.
01 BEERS-OUT PIC X(133).
*
WORKING-STORAGE SECTION.
01 FLAGS-COUNTERS-ACCUMULATORS.
05 FLAGS.
10 E-O-F PIC 9.
88 END-OF-FILE VALUE 1.
05 COUNTERS.
10 BOTTLES PIC 999
VALUE 0.
01 RECORD-OUT.
05 LINE1.
10 NUMBER-OF-BEERS-1 PIC ZZ9.
10 PIC X(28)
VALUE "BOTTLES OF BEER IN THE WALL ".
10 PIC
X
VALUE ",".
10 NUMBER-OF-BEERS-2 PIC ZZ9.
10 PIC
X.
10 PIC X(17)
VALUE "BOTTLES OF BEER.".
05 LINE2.
10 PIC X(34)
VALUE "TAKE ONE DOWN AND PASS IT ARROUND ".
10 NUMBER-OF-BEERS-3 PIC ZZ9.
10 PIC X.
10 PIC X(28)
VALUE "BOTTLES OF BEER IN THE WALL".
*
PROCEDURE DIVISION.
DRIVER-MODULE.
PERFORM INITIALIZATION.
PERFORM PROCESS UNTIL END-OF-FILE.
PERFORM TERMINATION.
STOP RUN.
*
INITIALIZATION.
OPEN OUTPUT OUTPUT-FILE.
ADD 100 TO BOTTLES.
*
PROCESS.
IF BOTTLES = 0 THEN
COMPUTE E-O-F = 1
ELSE PERFORM WRITE-ROUTINE
END-IF.
*
TERMINATION.
CLOSE OUTPUT-FILE.
*
WRITE-ROUTINE.
MOVE BOTTLES TO NUMBER-OF-BEERS-1, NUMBER-OF-BEERS-2.
COMPUTE BOTTLES = BOTTLES - 1.
WRITE BEERS-OUT FROM LINE1.
MOVE BOTTLES TO NUMBER-OF-BEERS-3.
WRITE BEERS-OUT FROM LINE2.
020107
...
Mahayana: Zakah: & Language Structures
Homer BASIC:

10 REM Homer 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 mmmmmm beer"
40 PRINT "Take one down {belch} and pass it around {belch},"
50 PRINT X-1;"bottle(s) of beer on the wall"
60 NEXT

~(_8^(|)
{repeat as necc.}
{{or as often as Moes is open}}
@@@8^)
020107
...
cube --------------------------------------------------------------------------------
// C version of 99 bottles of beer on the wall
for(x = 100; x 0; ){
printf("%3d bottles of beer on the wall ", x);
printf("take one down and pass it around ");
printf("%3d bottles of beer on the wall ", --x);
}

// normally we tab space for
// indentation, but the blather
// editor seems not to accept them
// ¹²³
020107
...
Mahayana: Zakah: & Language Structures
mathematically inclined

Aleph-null bottles of beer on the wall,
Aleph-null bottles of beer
You take one down & pass it around
Aleph-null bottles of beer
020107
...
Mahayana: Zakah: & Language Structures How about a little Zen beer?

No bottles of beer on the wall,
No bottles of beer.
Take one down, pass it around,
020107
...
cube Interesting. Blather editor doesn't accept newline characters '\nn' either... 020107
...
Mahayana: Zakah: & Language Structures /*
* 99 bottles of beer in ansi c
*
*/

#define MAXBEER (99)

void chug(int beers);

main()
{
register beers;

for(beers = MAXBEER; beers; chug(beers--))
puts("");

puts(" Time to buy more beer! ");

exit(0);
}

void chug(register beers)
{
char howmany[8], *s;

s = beers != 1 ? "s" : "";
printf("%d bottle%s of beer on the wall, ", beers, s);
printf("%d bottle%s of beeeeer . . . , ", beers, s);
printf("Take one down, pass it around, ");

if(--beers) sprintf(howmany, "%d", beers); else strcpy(howmany, "No more");
s = beers != 1 ? "s" : "";
printf("%s bottle%s of beer on the wall. ", howmany, s);
}

{{{dedicated 2 cube¹²³åßÇ}}}
020107
...
Mahayana: Zakah: & Language Structures Blather editor
doesn't accept:
+visa
+AMX
+TYme
+Discover
+WIC checks
+wooden nickels
+monopoly money
+nor far 2 many symbols

hey cube¹²³åßÇ
i wanna see
cube 'language'
make up yer own
if yer ^ 4 it

[[if there was cube language what would it be]][imagine creating languages based upon blather personalities][[:)]]
020107
...
Mahayana: Zakah: 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, "
#declare L2 = " of beer. "
#declare L3 = "Take one down and pass it around, "
#declare L4 = " of beer on the wall. "

#declare Beer = 99
#declare S2 = concat(str(Beer,0,0),S1)

#render " "

#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 } }

light_source { x*2, colour rgb 1 }

camera {
perspective
location x*2
look_at 0
}
020107
...
cube I love reading somebody else's C code. Using 'register' variables is seldom done any longer because the compiler figures out which variables to keep in register anyway. But, you did specify that it was ansii C (K&R) which is quite correct.

your (s = beers != 1 ? "s" : "";) is nice and tidy, too...

Who wrote it? ;-)
³
020107
...
Mahayana: Zakah: 'if' its tidy
'than' surely

mister tidy bowl
wrote it

¿[ring around your bowls collar]?
020107
...
Mahayana: Zakah: // C++ version of 99 Bottles of Beer, object oriented paradigm
#include

enum Bottle { BeerBottle };

class Shelf {
unsigned BottlesLeft;
public:
Shelf( unsigned bottlesbought )
: BottlesLeft( bottlesbought )
{}
void TakeOneDown()
{
if (!BottlesLeft)
throw BeerBottle;
BottlesLeft--;
}
operator int () { return BottlesLeft; }
};

int main( int, char ** )
{
Shelf Beer(99);
try {
for (;;) {
char *plural = (int)Beer !=1 ? "s" : "";
cout (int)Beer " bottle" plural
" of beer on the wall," endl;
cout (int)Beer " bottle" plural
" of beer," endl;
Beer.TakeOneDown();
cout "Take one down, pass it around," endl;
plural = (int)Beer !=1 ? "s":"";
cout (int)Beer " bottle" plural
" of beer on the wall." endl;
}
}
catch ( Bottle ) {
cout "Go to the store and buy some more," endl;
cout "99 bottles of beer on the wall." endl;
}
return 0;
}
020107
...
(outclassed) cube Leaves me in the dust...
³
020108
...
phil i hate programming 020422
...
Sailor Jupiter Well, that took the fun out of the song.
I remember sitting on the school bus on field trips in grade school screaming that song to bother teachers.
020422
...
Daria fify oow bowle ove beew on da waw. 020423
...
User24 in PHP:

0 ; $beers--)
{
if($beers==1) { $plural=""; }
echo "$beers Bottle$plural of Beer";
echo "hangin out on my wall";
echo "I take one down and pass it round you all";
echo "So now there's ";
}
echo "none.your round!";
?
030321
...
User24 Ok, NOW it works:

$plural = "s";
for($beers=99 ; $beers>0 ; $beers--)
{
if($beers==1) { $plural=""; }
echo "$beers Bottle$plural of Beer<br />";
echo "hangin out on my wall<br />";
echo "I take one down and pass it round you all<br /><br />";
echo "So now there's ";
}
echo "none.<br /><br />your round!";
030321
what's it to you?
who go
blather
from