99 Bottles of Beer
227 Computer Beer Styles
21303 visitors took one down since 7/21/96. This site chosen as the Geek Site of the Day for
March 19, 1997. For those arriving from there, I'd be honored to have you visit my Main
Web Pages.

Take One Down: A Brief History

Contributing

Strange Brew

Alphabetical List

Most Unique Languages

Beer Links

The Beer Listings
Take One Down: A Brief History
On a humor mailing list I was on in early '94, some nitwit posted the entire lyrics to "99
Bottles of Beer on the Wall." Needless to say, this was seen as a waste of bandwidth. The
first protest was that the job could have been accomplished with six lines of BASIC and
here were the six lines:
10
20
30
40
50
60
REM Basic version of 99 bottles of beer
FOR X=100 TO 1 STEP -1
PRINT X;"Bottle(s) of beer on the wall,";X;"bottle(s) of beer"
PRINT "Take one down and pass it around,"
PRINT X-1;"bottle(s) of beer on the wall"
NEXT
However, the complainer made the mistake of slighting C++ programmers, so I rose to
the occasion with my version of "99 Bottles" in C++. It opened the floodgates and
programmers from all over the world gave different versions in assorted languages. I
regret that I don't have the names to credit any of the programmers. However, if you spot
your handiwork in the collection, please send me your name and mail address in the form
of a comment in the appropriate language. (Or ask me to remove the code... I'm sure
somebody can write a replacement.)
Contributing
This list started with about 20 languages and ballooned from there. I had hoped that I
might someday get 99 languages. Well, the 99 came sooner that I expected. The Holiday
season of December 1995 apparently gave people the play-time it took to send me
programs. However, if you have a version of "99 Bottles" that isn't in this collection,
please e-mail me and I'll add it. But always bear in mind that if you wish to sing:
99 (0x63) Programming Languages on tape,
99 (0x63) Programming Languages.
Take C++ down,
Install all 'round,
98 (0x62) Programming Languages on tape,
and so on, then if you use this list for lyrics you will sing more than 99 verses. In any
event, if you contribute, if you could put your name in the form of your language's
comment style, that would be great. Known to me, but missing from this list are:

Jovial

Macsyma

JCL (I'm told this can't be done: No looping constructs.)

Orthogonal

Mixal

ADL

CMS-2

Chill

PL/M

MAD

Compact II

Cal

Euler

MIX (from Knuth's computer books)
Before you go to write something, please take a moment to check the actual body of this
web page for the language. Twice now I've left a language out of the index and had
people send me duplicates. Further, if you detect any link-rot -- whether internal to this
page or to reference sites -- please let me know.
1/3/98 note about the contributors: So far, the people contributing to the 99BoB page
have been the coolest people in the world. After submission, they clearly go over their
code again and submit corrections and improvements. The amount of works shown is
massive, but it's only the tip of the iceberg. You are only seeing the final products. They
have also shown the patience of Job waiting for me to get the contributions placed on the
web pages.
Strange Brew
This thing has become a monster! Since starting this project, I've gotten beer in some
obscure containers. For the sake of the unwashed masses, I've included brief descriptions
of the languages which, hopefully, won't detract from the code that follows.
The following gem should appeal to the mathematically inclined. (For the non
mathematically inclined, you might replace Aleph-null with infinity)
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
How about a little Zen beer?
No bottles of beer on the wall,
No bottles of beer.
Take one down, pass it around,
No bottles of beer on the wall.
If you don't want to go poking through the entire list, I made a collection of links to what
I consider the most unique languages. I don't state my reasons why I consider them
unique, I just listed the languages. One exception, Meta-HTML is the only program
source I know that you can actually run on the web. For those interested in older
computer languages, you might check out The Retrocomputing Museum.
This list came to the attention of my old Language Structures teacher at my Alma Mater.
The CLIPS contribution comes from a recent student of that class.
One of my contributors informed me that he had a heated discussion about programming
languages with his son's high-school math/computer teacher. The teacher was adamant
that there were no more than a dozen computer programming languages in the world. Ha,
ha. Guess again. As a cross-reference to the Babel of computer languages, see the Hello
World pages.
Back around '78 I found a Byte magazine survey of their readership that indicated that
only 1% of the readers were female. Things haven't changed much; Spring '97 I got 2
programs from ladies kind enough to make contributions.
The day before I got the geek-site award, the Befunge language was bestowed a similar
honor. For many months, work has prevented me from getting back this web page. In the
interim, I got dozens of Befunge programs. Befunge is the work of a twisted mind. Be
sure to check it out.
Tim Robinson
timtroyr@ionet.net
Back to the Funhouse
The List so far (227 entries):
1. A+
2. ABC
3. Abundance
4. Ada
5. ADL
6. AL
7. Algol 60
8. Amanda
9. Amiga Shell Script
10. AML
11. APL
12. APL2
13. Apple Script
14. ASP
15. Aspect
16. *Assembler
17. AWK
18. BASIC
19. BC
20. BCPL
21. Befdc
22. Befunge
23. Beta
24. Blank
25. Bliss
26. Bobo
27. Bourne Shell
28. Bourne Again Shell
29. Boxer Macro Language
30. Brainf***
31. BS
32. C
33. C++
34. C/C++ Pre-processor
35. C-shell
36. CAML
37. CAL
38. calc
39. CDC NOS CCL
40. CL
41. Chill/2
42. Clipper
43. CLIPS
44. CLIST
45. CLOS
46. CLU
47. COBOL
48. CorVu
49. Cold Fusion
50. Common Lisp
51. Concurrent Clean
52. CUPL
53. DAL
54. dBase III
55. dc
56. dc_shell script
57. DECTPU
58. Delphi
59. Dialog System
60. DIBOL
61. DOS batch
62. Draco
63. DSSP
64. Dylan
65. E
66. Eiffel
67. Emacs Lisp
68. Erlang
69. Excel
70. EXEC
71. Expect
72. Express
73. False
74. FileMaker Pro
75. Focal
76. Focus
77. Forms/3
78. Forth
79. Fortran IV
80. Fortran 77
81. Foxpro/Xbase
82. Froth
83. Fortran 90
84. GNU-CPP
85. Gofer
86. GrASP
87. hackMongo
88. Haskell
89. Hope
90. HyperTalk
91. Icon
92. IDL
93. ILE AS/400
94. Inform
95. Inform 6
96. INTERCAL
97. IRC II
98. ISM/SML
99. ITCL
100.
Jam
101.
Java
102.
Java Script
103.
K
104.
Kermit Script
105.
KidSim
106.
Korn Shell
107.
KUIP
108.
Labview
109.
Lakota
110.
Leda
111.
LIFE
112.
Limbo
113.
Lingo
114.
Logo
115.
LPC
116.
Luck
117.
M-Speak
118.
M4
119.
M5
120.
Mac Wordperfect
121.
MAGIC/L
122.
Magma
123.
Make
124.
Maple
125.
Mark IV
126.
MATLAB
127.
Mathematica
128.
Mercury
129.
Meta-HTML
130.
Meta Post
131.
Miranda
132.
Microsoft Word
133.
ML
134.
Model 204
135.
Modula 2
136.
Modula 3
137.
MOO
138.
Mops
139.
MPTMON
140.
Mumps
141.
MUSH/TinyTIM/TinyMUSH
142.
Natural
143.
Navel
144.
NEWLIB
145.
NewtonScript
146.
NIAL
147.
nroff
148.
Oberon
149.
Occam
150.
OCL
151.
OPL
152.
Orthogonal
153.
PAL
154.
Pascal
155.
Perl
156.
PH/FI
157.
Pilot
158.
PLEX
159.
PL/I
160.
PL/M-80
161.
PL/SQL
162.
POP
163.
*Pocket Programmable Calculators
164.
Posix
165.
POV-Ray
166.
Postscript
167.
Prolog
168.
Prograph
169.
Progress
170.
PV-Wave
171.
Python
172.
Quick Basic
173.
Rapid
174.
rc
175.
REXX
176.
RPG/400
177.
SAS
178.
SAUL
179.
Sather
180.
Scheme
181.
sed
182.
Sendmail
183.
SETL
184.
Silk
185.
Simscript
186.
Simula
187.
Sisal
188.
Smalltalk
189.
SML
190.
SNOBOL
191.
SPITBOL
192.
SPSS
193.
SQL
194.
SR
195.
Superbase SBL
196.
SuperTalk
197.
Surf
198.
TCL
199.
TECO
200.
Terse
201.
troff
202.
TeX/LaTeX
203.
TinTin
204.
Tiny Fugue
205.
Turing
206.
Turing Machine
207.
TUTOR
208.
Trac
209.
Transact SQL
210.
Trumpet
211.
Unix DC
212.
Vax DCL
213.
UltraMacros
214.
Usertalk
215.
Verilog
216.
VHDL
217.
Visual Basic
218.
vi
219.
VICC
220.
VIM
221.
VScript
222.
Word Basic
223.
YACC
224.
Yorick
225.
zsh
226.
4DOS Batch
227.
4Test
Most Unique Languages

APL2

Befunge

Brainf***

Common Lisp

Forth

Make

Meta-HTML

Mumps

MUSH/TinyTIM/TinyMUSH

PAL

Prograph

Prolog

RPG/400

TECO

YACC
Cyber-Beer:
Beer Homebrewing Guide
BeerMasters Tasting Society
Yahoo Beer Links
The Programs:
This got too big to keep on one page. To see the list of 99BoB programs in chunks, click
here
Compilation Copyright 1995-1998 Tim Robinson. All Rights Reserved
Permission to copy enthusiastically granted to instructors of computer science
(who would like to demonstrate the styles of different programming languages
to their students) provided that the names of the contributors are retained.
Back to the Funhouse
C++
// C++ version of 99 Bottles of beer
// programmer: Tim Robinson timtroyr@ionet.net
#include <fstream.h>
int main()
{
int bottles = 99;
while ( bottles > 0 )
{
cout << bottles << " bottle(s) of beer on the wall," << endl;
cout << bottles << " bottle(s) of beer." << endl;
cout << "Take one down, pass it around," << endl;
cout << --bottles << " bottle(s) of beer on the wall." << endl;
}
return 0;
}
This is how C++ is supposed to be used.
// C++ version of 99 Bottles of Beer, object oriented paradigm
// programmer: Tim Robinson timtroyr@ionet.net
#include <fstream.h
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;
}
And one more version that may be called "abuse" by some, but here it is:
// 99 bottles of beer, C++ template 'meta-programming' version
// By Arion Lei (philipl@cs.ust.hk)
#include <iostream.h>
template<int I>
class Loop {
public:
static inline void f () {
cout << I << " bottles of beer on the wall," << endl
<< I << " bottles of beer." << endl
<< "Take one down, pass it around," << endl
<< I-1 << " bottles of beer on the wall." << endl;
Loop<I-1>::f();
}
};
class Loop<0> {
public:
static inline void f () {
cout << "Go to the store and buy some more," << endl
<< "99 bottles of beer on the wall." << endl;
}
};
int main () {
Loop<3>::f();
return 0;
}
COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID.BOTTLES_OF_BEER.
AUTHOR.DONALD FRASER.
*
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
88 END-OF-FILE
05 COUNTERS.
10 BOTTLES
PIC 9.
VALUE 1.
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.
C
/*
* 99 bottles of beer in ansi c
*
* by Bill Wein: bearheart@bearnet.com
*
*/
#define MAXBEER (99)
void chug(int beers);
main()
{
register beers;
for(beers = MAXBEER; beers; chug(beers--))
puts("");
puts("\nTime to buy more beer!\n");
exit(0);
}
void chug(register beers)
{
char howmany[8], *s;
s = beers != 1 ? "s" :
printf("%d bottle%s of
printf("%d bottle%s of
printf("Take one down,
"";
beer on the wall,\n", beers, s);
beeeeer . . . ,\n", beers, s);
pass it around,\n");
if(--beers) sprintf(howmany, "%d", beers); else strcpy(howmany, "No
more");
s = beers != 1 ? "s" : "";
printf("%s bottle%s of beer on the wall.\n", howmany, s);
}
Ada
/* Ada version of 99 Bottles of Beer */
with TEXT_IO; use TEXT_IO;
procedure BOTTLES is
package INT_IO is new INTEGER_IO (INTEGER);
use INT_IO;
COUNT : INTEGER := 99;
begin
while COUNT > 0 loop
PUT (COUNT,WIDTH=0); PUT_LINE (" bottles of beer on the wall,");
PUT (COUNT,WIDTH=0); PUT_LINE (" bottles of beer.");
PUT_LINE ("Take one down and pass it around.");
COUNT := COUNT - 1;
if COUNT = 0 then
PUT_LINE("No bottles of beer on the wall!");
else
PUT (COUNT,WIDTH=0); PUT_LINE (" bottles of beer on the
wall.");
end if;
NEW_LINE;
end loop;
end BOTTLES;
I hesitate to include the following code, but it's what Ada was created for.
-- Just for amusement, here's a multi-tasking version.
-- Ten customers enter bar to sing and drink. Bartender serializes
-- access to 'take one down' to avoid fights
-- contributed by tmoran@bix.com
with Text_IO;
procedure Bar is
Out_Of_Beer : Exception;
protected Bartender is
function Count return Integer;
procedure Take_One_Down;
private
Remaining : Integer range 0 .. 99 := 99;
end Bartender;
protected body Bartender is
function Count return Integer is
begin return Remaining; end Count;
procedure Take_One_Down is
begin
if Remaining = 0 then raise Out_Of_Beer;
else Remaining := Remaining - 1;
end if;
end Take_One_Down;
end Bartender;
type Names is (Charles, Ada, John, Grace, Donald,
Edsger, Niklaus, Seymour, Fred, Harlan);
task type Customers is
entry Enter_Bar(Who : in Names);
end Customers;
Customer_List : array(Names) of Customers;
task body Customers is
Me : Names;
procedure Sing_And_Drink(Singer_ID : in String) is
procedure Sing(S : in String) renames Text_IO.Put_Line;
begin
loop
declare
Bottle_Part : constant String
:= Integer'image(Bartender.Count) & " bottles of beer";
begin
Sing(Bottle_Part & " on the wall" & Singer_ID);
Sing(Bottle_Part & Singer_ID);
end;
Sing(" Take one down and pass it arround" & Singer_ID);
Bartender.Take_One_Down;
delay 10.0; -- allow ten seconds to gulp one down
end loop;
exception
when Out_Of_Beer = Sing("no more beer!" & Singer_ID);
end Sing_And_Drink;
begin -- customer task
accept Enter_Bar(Who : in Names) do
Me := Who;
end Enter_Bar;
Sing_And_Drink(" - " & Names'image(Me));
end Customers;
begin -- operating bar
for Person in Customer_List'range loop
Customer_List(Person).Enter_Bar(Person);
delay 2.0; -- allow two seconds between customers entering bar
end loop;
end Bar;
C-Shell
#!/bin/csh
#
# C-Shell script version of 99 Bottles of Beer
#
set i = 100
while ($i > 0)
echo -n $i " bottles of beer on the wall"
echo $i " bottles of beer......"
set i = `expr $i - 1`
echo -n "take one down pass it around, " $i
echo "bottles of beer on the wall"
end
--- A noteworthy alternative
#!/bin/csh
# Version #2.1 C-Shell version of 99 Bottles of Beer
#
# overhauled 1997-19-3 by Ken Bateman (kbateman@esinet.net)
#
foreach i (9 8 7 6 5 4 3 2 1 " ")
foreach j (9 8 7 6 5 4 3 2 1 0)
if ( $i$j != "99" ) echo $i$j " bottles of beer on the wall"
echo -n $i$j "bottles of beer on the wall, "
echo $i$j "bottles of beer"
echo -n "Take one down, pass it around..."
end
end
echo "no more bottles of beer on the wall"
echo "No more bottles of beer on the wall, no more bottles of beer"
echo "Go to the store, buy some more,"
echo "99 bottles of beer on the wall"
#end of script
AWK
#!/usr/bin/awk -f
#
awk version of 99 bottles of beer
#
by Whitey (whitey@netcom.com) - 06/05/95
BEGIN {
for(i = 99; i > 0; i--) {
print s = bottle(i), "on the wall,", s ","
print "take one down, pass it around,"
print bottle(i - 1), "on the wall."
}
}
function bottle(n) {
return sprintf("%s bottle%s of beer", n ? n : "no more", n - 1 ? "s" :
"")
}
Bourne Shell
#!/bin/sh
# Bourne shell version of 99 Bottles
# Craig J Copi - copi@oddjob.uchicago.edu
#
if [ $# -eq 1 ]; then
beers=$1
else
beers=99
fi
s="s"
while [ $beers -gt 0 ]; do
echo "$beers bottle$s of beer on the wall,"
echo "$beers bottle$s of beer,"
echo "take one down, pass it around,"
beers=`expr $beers - 1`
if [ $beers -ne 0 ]; then
test $beers -eq 1 && s=""
echo "$beers bottle$s of beer on the wall."
else
echo "no bottles of beer on the wall."
fi
echo
done
echo
echo "Time to buy some more beer . . . ."
Common Lisp
;; Bottles by Rebecca Walpole (walpolr@cs.orst.edu)
;; tested in Austin Kyoto Common Lisp version 1.615
;; Note: the ~p takes care of plurals.
;;
(defun bottles (n)
"Prints the lyrics to '99 Bottles of Beer'"
(if (< n 1)
(format t "~%Time to go to the store.~%")
(progn (format t "~% ~a bottle~:p of beer on the wall." n)
(format t "~% ~a bottle~:p of beer." n)
(format t "~% Take one down, pass it around.")
(format t "~% ~a bottle~:p of beer on the wall.~%" (- n 1))
(bottles (- n 1))
)
)
)
(bottles 99)
AML
/* AML (Arc Macro Language) version of 99 bottles of beer on the wall
/* Author prefers anonymity B-)
/*
&do number = 9 &to 1 &by -1
/* handle the one bottle cases
&if %number% = 1 &then
&set noun1 = bottle
&else
&set noun1 = bottles
&if %number% = 2 &then
&set noun2 = bottle
&else
&set noun2 = bottles
&type
&type
&type
&type
\%number% %noun1% of beer on the wall,
%number% %noun1% of beer,
Take one down, pass it around,
[calc %number% - 1] %noun2% of beer on the wall
&end
&return
Beta
Click for information.
ORIGIN '~beta/basiclib/v1.4/betaenv';
--- program: descriptor --(* 99 bottles in BETA. Ole Villumsen, October 27, 1995. *)
(# putBottles: (# no: @integer;
enter no
do (if no//1 then '1 bottle' - putLine;
else no - putInt; ' bottles' - putText;
if);
#);
do (for i:99 repeat
100-i - putBottles; ' of beer on the wall,' - putLine;
100-i - putBottles; ' of beer.' - putLine;
'Take one down, pass it around,' - putLine;
99-1 - putBottles; ' of beer on the wall.' - putLine; newLine;
for)
#)
Clipper
/* Tim Nason, 27 Oct 95 */
procedure beer
local nBeers := 99
while .t.
?
? alltrim( str( nBeers ) ) + ' bottle' + iif( nBeers = 1, '', 's'
) + ;
' of beer on the wall.'
? alltrim( str( nBeers ) ) + ' bottle' + iif( nBeers-- = 1, '',
's' ) + ;
' of beer.'
if nBeers < 0
? "Go to the store and buy some more."
nBeers := 99
? '99 bottles of beer on the wall.'
else
? 'Take one down, pass it around,'
? alltrim( str( nBeers ) ) + ' bottles of beer on the wall.'
endif
enddo
return
Algol 60
BEGIN
FILE TERM(KIND=REMOTE,MYUSE=OUT);
EBCDIC ARRAY OUTLINE[0:72];
PROCEDURE BOTTLECOUNT(I,P);
VALUE I; INTEGER I;
POINTER P;
BEGIN
REPLACE P:P BY I FOR * DIGITS, " bottle",
IF I NEQ 1 THEN "s " ELSE " ";
END;
POINTER OP;
INTEGER BOTTLES;
BOTTLES := 99;
FOR BOTTLES := 99 STEP -1 UNTIL 1 DO BEGIN
OP := OUTLINE;
BOTTLECOUNT(BOTTLES,OP);
REPLACE OP:OP BY "of beer on the wall,";
WRITE(TERM,<A72>,OUTLINE);
OP := OUTLINE;
BOTTLECOUNT(BOTTLES,OP);
REPLACE OP:OP BY "of beer,";
WRITE(TERM,<A72>,OUTLINE);
WRITE(TERM,<"You take one down and pass it around,");
OP := OUTLINE;
BOTTLECOUNT(BOTTLES-1,OP);
REPLACE OP:OP BY "of beer on the wall.";
WRITE(TERM,<A72>,OUTLINE);
END FOR;
END.
Algol 68
#
#
(
;
99 Bottles of Beer
#
by Otto Stolz <Otto.Stolz@Uni-Konstanz.de> #
PROC width = (INT x) INT: (x9 | 2 | 1)
FOR i FROM 99 BY -1 TO 1
DO printf ( ( $ 2l n(width(i))d
, x "bottle" b("","s") x "of beer on the wall,"
, x n(width(i))d
, x "bottle" b("","s") x "of beer."
, l "Take one down, pass it around,"
, x n(width(i-1))d
, x "bottle" b("","s") x "of beer."
$
, i , i=1
, i , i=1
, i-1, i=2
) )
OD
)
Apple Script
-- AppleScript version of "99 Bottles of Beer"
-- by Kristopher Johnson kdj@mindspring.com
to createBottleString for aNumberOfBottles
if aNumberOfBottles is 0 then
return "No more bottles"
else if aNumberOfBottles is 1 then
return "1 more bottle"
else
return (aNumberOfBottles as string) & " bottles"
end if
end createBottleString
set lyrics to ""
repeat with numberOfBottles from 99 to 1 by -1
set bottleString to (createBottleString for numberOfBottles)
set lyrics to lyrics & bottleString & " of beer on the wall, " &
bottleString & " of beer. " & return
set lyrics to lyrics & "Take one down and pass it around, " & return
set lyrics to lyrics & (createBottleString for (numberOfBottles - 1))
& " of beer on the wall. " & return
end repeat
set lyrics to lyrics & "No more bottles of beer on the wall, no more
bottles of beer." & return
set lyrics to lyrics & "Go to the store and buy some more." & return
set lyrics to lyrics & "99 bottles of beer on the wall."
return lyrics
APL
APL2
BCPL
// BCPL version of 99 Bottles of Beer.
// hacked by Akira KIDA <SDI00379@niftyserve.or.jp>
GET "LIBHDR"
MANIFEST $(
BOTTLES = 99
$)
LET START() BE $(
LET BEERS(N, S) BE $(
TEST N = 0 THEN WRITEF("No more bottles")
ELSE WRITEF("%N bottle%S", N, (N = 1) - "", "s")
WRITEF(" of beer%S", S)
$)
FOR I = BOTTLES TO 1 BY -1 DO $(
BEERS(I, " on the wall, ")
BEERS(I, ".*NTake one down, pass it around.*N")
BEERS(I - 1, " on the wall.*N")
$)
FINISH
$)
Concurrent Clean
//language Concurrent Clean - lazy pure functional
// Author: Jan Krynicky (jkry3025@comenius.mff.cuni.cz)
module beer
import StdEnv
//run with console and no constructors (don't want to make windows, menu
...)
Start = genbeer 99
where
genbeer 0 = ["No more bottles of beer on the wall.\n", //We are all
drunk enough.
"No more bottles of beer.\n",
//so sad!
"Go to the store and buy some more.\n"
//If you can fin
it.
: genbeer 99]
//Go on, let's drink forever.
genbeer n = [sn+++" Bottle(s) of beer on the wall, "
+++ sn +++ " bottle(s) of beer.\n",
"Take one down and pass it around.\n",
toString(n-1)+++ " bottle(s) of beer on the wall."
:genbeer (n-1)]
where
ns = toString(n)
//end
CAML
More Informatin
(* Caml Light version of 99 bottles of beer *)
(* Written by Bow-Yaw Wang (bywang@saul.cis.upenn.edu) *)
let rec bottles =
function 1 - print_string "1 bottle of beer on the wall, 1 bottle of
beer\n";
print_string "Take one down, pass it around,\n";
print_string "no more bottles of beer on the wall\n"
| n - print_int n;
print_string " bottles of beer on the wall, ";
print_int n;
print_string " bottles of beer\n";
print_string "Take one down and pass it around,\n";
print_int (n-1);
print_string " bottles of beer on the wall\n";
bottles (n-1)
in
bottles 99;;
CLU
% 99 bottles of beer in CLU by dcurtis@lcs.mit.edu
start_up = proc()
po: stream := stream$primary_output()
for i: int in int$from_to_by(99, 1, -1) do
if i = 1 then
stream$putl(po, int$unparse(i) || " bottle of beer on the wall")
stream$putl(po, int$unparse(i) || " bottle of beer...")
else
stream$putl(po, int$unparse(i) || " bottles of beer on the wall")
stream$putl(po, int$unparse(i) || " bottles of beer...")
end
stream$putl(po, "Take one down, pass it around...")
end
stream$putl(po, "\nTime to get more beer!")
end start_up
CLIPS
Clips is available for Mac, Windows, Unix, and perhaps a few others. Developed by NASA,
and used as a language for AI and Knowledge Based Systems.
;Written by Bill Ensinger (Bill222E@aol.com) on Saturday February 24, 1996
;8:00 - 9:41 pm Eastern Standard time at Taylor University.
;All praise to God; note that we just pass the beer, but don't drink!
(deftemplate beer
(field ninetynine))
(deffacts bottles
(beer (ninetynine 99)))
(defrule Bottlesninetynine ""
(beer (ninetynine ?bottlenum))
?fl ?bottlenum 2))
=
(printout t ?bottlenum " bottles of beer on the wall," t)
(printout t ?bottlenum " bottles of beer." t)
(printout t "Take one down, pass it around," t)
(printout t (- ?bottlenum 1) " bottles of beer on the wall." t)
(printout t " " t)
(modify ?fl (ninetynine =(- ?bottlenum 1)))
)
(defrule Bottlestwo ""
(beer (ninetynine 2))
?fl
(printout t ?bottlenum " bottles of beer on the wall," t)
(printout t ?bottlenum " bottles of beer." t)
(printout t "Take one down, pass it around," t)
(printout t (- ?bottlenum 1) " bottle of beer on the wall." t)
(printout t " " t)
(modify ?fl (ninetynine =(- ?bottlenum 1)))
)
(defrule Bottlesone ""
(beer (ninetynine 1))
?fl
(printout
(printout
(printout
(printout
t
t
t
t
?bottlenum " bottle of beer on the wall," t)
?bottlenum " bottle of beer." t)
"Take one down, pass it around," t)
"No more bottles of beer on the wall!" t)
)
Amiga Shell Script
The original Amiga Shell script before REXX took over.
.key num_bottles
set count
set bword "bottles"
LAB LOOP
echo $count $bword "of beer on the wall."
echo $count $bword "of beer."
echo "Take one down, pass it around."
set count `eval $count - 1`
if $count eq 1
set bword "bottle"
else
set bword "bottles"
endif
echo $count $bword "of beer."
echo ""
if $count gt 0
skip LOOP BACK
endif
COMAL
Common Algorithmic Language.
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
// bottles of beer
FOR x# := 99 TO 1 STEP -1 DO
bottles(x#, TRUE)
bottles(x#, FALSE)
PRINT "Take one down, pass it around."
bottles(x#-1, FALSE)
ENDFOR num
END
0110
0120
0130
0140
0150
0160
0170
0180
0190
0200
0210
0220
0230
0240
0250
0260
0270
0280
PROC bottles(num#, wall) CLOSED
PRINT num#;
text$ := "bottle"
IF num# <> 1 THEN
text$ := text$ + "s"
ENDIF
PRINT text$," of beer";
IF wall = TRUE
PRINT "on the wall";
ENDIF
PRINT "."
ENDPROC bottles
Bourne Again Shell
The only possible explanation for the existence of this shell in addition to the Bourne shell is
that programmers have no lives... if this web page wasn't already proof.
#!/bin/bash
# Bourne Again shell version of 99 Bottles
# Dave Plonka - plonka@carroll1.cc.edu
typeset -i n=99
typeset bottles=bottles
typeset no
while [ 0 != $[ n ] ]
do
echo "${n?} ${bottles?} of beer on the wall,"
echo "${n?} ${bottles?} of beer,"
echo "take one down, pass it around,"
n=n-1
case ${n?} in
0)
no=no
bottles=${bottles%s}s
;;
1)
bottles=${bottles%s}
;;
esac
echo "${no:-${n}} ${bottles?} of beer on the wall."
echo
done
exit
BS
Appears to be a combination of Basic and Snobol with a little C thrown in.
#!/usr/bin/bs
# bs version of 99 Bottles
# Dave Plonka - plonka@carroll1.cc.edu
# Thu Aug 8 1996
fun sing(n, end) s
s = ("s", "")[ match(n, "^1$") ]
put = format(format(format("%s bottle%%s of beer%%%%s", n), s), end)
nuf
for n = 99, n, put = ""
sing(format("%-0.0f", n), " on the wall,")
sing(format("%-0.0f", n), ",")
put = "take one down, pass it around,"
--n
sing((format("%-0.0f", n), "no")[ 0 == n ], " on the wall.")
next
run
exit
CL
A programming language for the IBM AS/400
PGM
/* 99 Bottles of Beer in AS/400 CL (Command Language)
/* Programmer: Werner Grzemba, 101326.3300@compuserve.com
*/
*/
/*
/*
*/
*/
To avoid the necessity of any user action, the output is
sent to the status line (except of the buy-request at end)
DCL
DCL
DCL
DCL
DCL
VAR(&MSG) TYPE(*CHAR) LEN(79)
VAR(&BEER1) TYPE(*CHAR) LEN(30) VALUE(' +
bottles of beer on the wall, ')
VAR(&BEER2) TYPE(*CHAR) LEN(31) VALUE('Take +
one down, pass it around, ')
VAR(&BEER3) TYPE(*CHAR) LEN(78) VALUE('Go +
to the store and by some more... 99 +
bottles of beer')
VAR(&BOTTLES) TYPE(*DEC) LEN(2 0) VALUE(99)
DCL
DCL
VAR(&XB) TYPE(*CHAR) LEN(2)
VAR(&RPY) TYPE(*CHAR) LEN(4)
CHGVAR
VAR(&XB) VALUE(&BOTTLES)
CHGVAR
VAR(&MSG) VALUE(&XB *CAT &BEER1 *CAT &XB +
*CAT %SST(&BEER1 1 16))
MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) +
TOPGMQ(*EXT) MSGTYPE(*STATUS)
DLY(1)
VAR(&BOTTLES) VALUE(&BOTTLES - 1)
VAR(&XB) VALUE(&BOTTLES)
VAR(&MSG) VALUE(&BEER2 *CAT &XB *CAT +
%SST(&BEER1 1 28))
MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) +
TOPGMQ(*EXT) MSGTYPE(*STATUS)
DLY(1)
COND(&BOTTLES 0) THEN(GOTO CMDLBL(MOREBEER))
MOREBEER:
SNDPGMMSG
DLYJOB
CHGVAR
CHGVAR
CHGVAR
SNDPGMMSG
DLYJOB
IF
CHGVAR
SNDPGMMSG
DLYJOB
SNDPGMMSG
VAR(&MSG) VALUE('No more' *CAT &BEER1 *CAT +
'no more' *CAT %SST(&BEER1 1 16))
MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) +
TOPGMQ(*EXT) MSGTYPE(*STATUS)
DLY(2)
MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&BEER3) +
TOPGMQ(*EXT) MSGTYPE(*INQ) KEYVAR(&RPY)
ENDPGM
CLIST
An outdated IBM batch language.
/* THIS IS WRITTEN IN CLIST - A IBM MVS/TSO BATCH LANGUAGE
/* THIS LINE IS A COMMENT
/* ALEX V FLINSCH SPARROWHAWK@WORLDNET.ATT.NET
PROC 0
SET BEER=99
A: WRITE &BEER BOTTLES OF BEER ON THE WALL
WRITE &BEER BOTTLES OF BEER
WRITE TAKE ONE DOWN AND PASS IT AROUND
SET BEER=&EVAL(&BEER-1)
IF &BEER ,= 0 THEN GOTO A
WRITE NO MORE BOTTLES OF BEER ON THE WALL
WRITE NO MORE BOTTLES OF BEER
BC
/*
*/
/*
/*
*/
/*
*/
/*
*/
99 bottles of beer in Unix bc
by Adam Roach
*/
In theory, this could be shortened by functions, but the version of
bc that I have access to doesn't allow functions... so this is long...
i = 99
while ( i 0 ) {
if (i/10 == 1) "1"
if (i/10 == 2) "2"
if (i/10 == 3) "3"
if (i/10 == 4) "4"
if (i/10 == 5) "5"
if (i/10 == 6) "6"
if (i/10 == 7) "7"
if (i/10 == 8) "8"
if (i/10 == 9) "9"
if (i%10 == 0) "0 bottle"
if (i%10 == 1) "1 bottle"
if (i%10 == 2) "2 bottle"
if (i%10 == 3) "3 bottle"
if (i%10 == 4) "4 bottle"
if (i%10 == 5) "5 bottle"
if (i%10 == 6) "6 bottle"
if (i%10 == 7) "7 bottle"
if (i%10 == 8) "8 bottle"
if (i%10 == 9) "9 bottle"
if (i != 1) "s"
" of beer on the wall,
"
if (i/10 == 1) "1"
if (i/10 == 2) "2"
if (i/10 == 3) "3"
if (i/10 == 4) "4"
if (i/10 == 5) "5"
if (i/10 == 6) "6"
if (i/10 == 7) "7"
if (i/10 == 8) "8"
if (i/10 == 9) "9"
if (i%10 == 0) "0 bottle"
if (i%10 == 1) "1 bottle"
if (i%10 == 2) "2 bottle"
if (i%10 == 3) "3 bottle"
if (i%10 == 4) "4 bottle"
if (i%10 == 5) "5 bottle"
if (i%10 == 6) "6 bottle"
if (i%10 ==
if (i%10 ==
if (i%10 ==
if (i != 1)
" of beer.
7) "7 bottle"
8) "8 bottle"
9) "9 bottle"
"s"
"
i = i - 1
"Take one down, pass it around.
"
if (i/10 == 1) "1"
if (i/10 == 2) "2"
if (i/10 == 3) "3"
if (i/10 == 4) "4"
if (i/10 == 5) "5"
if (i/10 == 6) "6"
if (i/10 == 7) "7"
if (i/10 == 8) "8"
if (i/10 == 9) "9"
if (i%10 == 0) "0 bottle"
if (i%10 == 1) "1 bottle"
if (i%10 == 2) "2 bottle"
if (i%10 == 3) "3 bottle"
if (i%10 == 4) "4 bottle"
if (i%10 == 5) "5 bottle"
if (i%10 == 6) "6 bottle"
if (i%10 == 7) "7 bottle"
if (i%10 == 8) "8 bottle"
if (i%10 == 9) "9 bottle"
if (i != 1) "s"
" of beer on the wall.
"
}
quit
ABC
ABC was developed at CWI in the Netherlands.
PUT "by Whitey (whitey@netcom.com) - 10/13/96" IN author
HOW TO RETURN verse n:
SELECT:
n = 0:
PUT "no more bottles of beer" IN s
n = 1:
PUT "1 bottle of beer" IN s
ELSE:
PUT "`n` bottles of beer" IN s
RETURN s
HOW TO DRINK:
PUT 99 IN num
WHILE num 0:
WRITE verse
WRITE "take
PUT num - 1
WRITE verse
num, " on the wall, ", verse num, "," /
one down, pass it around," /
IN num
num, " on the wall." /
DRINK
Bliss
There are two versions here: one is done procedurally, the second is more in keeping with
Bliss's style.
module NINTY_NINE_BOTTLES (main=BOTTLES) =
!
!
"99 Bottles of Beer on the Wall"
!
using BLISS on DIGITAL's Alpha OpenVMS
!
by Ron Brender, brender@zko.dec.com
!
begin
forward routine
BOTTLES
: novalue,
BOTTLE_S
: novalue,
BOTTLE_COUNT
: novalue;
external routine
printf
:
!
!
!
!
novalue
! Main routine
! 'bottle<s>'
! <n> or 'no'
external_name('DECC$GXPRINTF');
To "port" this program to UNIX or WNT, use
external_name('printf') or the appropriate lower case
compilation option instead of the above.
macro
PUT_TEXT(T) =
printf(uplit(%asciz '%s'), uplit(%asciz T))
%,
PUT_INT(N) =
printf(uplit(%asciz '%*d'), if N lss 10 then 1 else 2, N)
%,
PUT_NL (dummy) =
printf(uplit(%asciz %string(%char(10))))
%;
global routine BOTTLES : novalue =
begin
! Title
!
PUT_NL();
PUT_TEXT('
PUT_NL();
"99 Bottles of Beer on the Wall"'); PUT_NL();
decr I from 99 to 1 do
begin
! <n> bottle<s> of beer on the wall; <n> bottle<s> of beer
!
BOTTLE_COUNT(.I); PUT_TEXT(' '); BOTTLE_S(.I);
PUT_TEXT(' of beer on the wall; ');
BOTTLE_COUNT(.I); PUT_TEXT(' '); BOTTLE_S(.I); PUT_TEXT(' of beer');
PUT_NL();
! Take <one|it> down and pass it around
!
PUT_TEXT('Take ');
if .I eql 1 then PUT_TEXT('it') else PUT_TEXT('one');
PUT_TEXT(' down and pass it around'); PUT_NL();
! <n-1> bottle<s> of beer on the wall
!
BOTTLE_COUNT(.I-1); PUT_TEXT(' '); BOTTLE_S(.I-1);
PUT_TEXT(' of beer on the wall'); PUT_NL();
! New stanza
!
PUT_NL();
end;
end;
routine BOTTLE_S (COUNT) : novalue =
begin
PUT_TEXT('bottle');
if .COUNT neq 1 then PUT_TEXT('s');
end;
routine BOTTLE_COUNT (COUNT) : novalue =
if .COUNT eql 0 then PUT_TEXT('No') else PUT_INT(.COUNT);
end
eludom
Version #2
module NINTY_NINE_BOTTLES_CT (main=BOTTLES) =
!
!
"99 Bottles of Beer on the Wall"
!
using BLISS on DIGITAL's Alpha OpenVMS
!
by Ron Brender, brender@zko.dec.com
!
begin
external routine
printf
:
!
!
!
!
novalue
external_name('DECC$GXPRINTF');
To "port" this program to UNIX or WNT, use
external_name('printf') or the appropriate lower case
compilation option instead of the above.
macro
PUT_TEXT(T) =
printf(uplit(%asciz '%s'), uplit(%asciz T))
%,
PUT_NL (dummy) =
printf(uplit(%asciz %string(%char(10))))
%;
compiletime
TEMP = 0;
! In principle, the complete text can be constructed at compile-time and
! output with a single PUT_TEXT call, however, that runs up against a
! compile-time maximum string length. This implementation constructs a
! complete stanza at compile-time.
!
macro
BOTTLE_S(COUNT) =
%if COUNT eql 1 %then 'bottle' %else 'bottles' %fi
%,
BOTTLE_COUNT(COUNT) =
%assign(TEMP, COUNT)
%if TEMP eql 0 %then 'No' %else %string(%number(TEMP)) %fi
%,
BOTTLE_STANZA(COUNT) =
PUT_TEXT(%string(
BOTTLE_COUNT(COUNT), ' ', BOTTLE_S(COUNT),
' of beer on the wall; ',
BOTTLE_COUNT(COUNT), ' ', BOTTLE_S(COUNT), ' of beer', %char(10),
'Take one down and pass it around', %char(10),
BOTTLE_COUNT(COUNT-1), ' ', BOTTLE_S(COUNT-1),
' of beer on the wall', %char(10),
%char(10)))
%,
BOTTLE_TEXT(COUNT)[] =
BOTTLE_STANZA(COUNT);
%if COUNT gtr 1 %then
BOTTLE_TEXT(COUNT - 1)
%fi
%;
global routine BOTTLES : novalue =
begin
! Title
!
PUT_NL();
PUT_TEXT('
PUT_NL();
"99 Bottles of Beer on the Wall"'); PUT_NL();
BOTTLE_TEXT(99);
end;
end
eludom
calc
/*
* 99 bottles of beer
*
* See:
*
http://reality.sgi.com/csp/ioccc/noll/noll.html#calc
*/
for (i=99; i 0;) {
/* current wall state */
some_bottles = (i != 1) ? "bottles" : "bottle";
print i, some_bottles, "of beer on the wall,",;
print i, some_bottles, "of beer!";
/* glug, glug */
--i;
print "Take one down and pass it around,",;
/* new wall state */
less = (i 0) ? i : "no";
bottles = (i!=1) ? "bottles" : "bottle";
print less, bottles, "of beer on the wall!\n";
}
Bobo
The author (below) created the language. "Bobo" is Spanish for idiot. Good enough
description for a computer in general if you ask me.
## 99.bb v1.2
## Bayard W. Wenzel
# some handy macros
/nprint {"\n" add print} def
/space {"\n" 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
Chill/2
io: MODULE
/*
The CHILL/2 compiler I use has no VARYING strings.
To tackle this inconvenience, I declare a record with variants..
*/
GRANT String, nul, OutS, OutL, OutC, OutI;
NEWMODE String = STRUCT(CASE OF
:s9 CHAR(9),
:s11 CHAR(11),
:s13 CHAR(13),
:s16 CHAR(16),
:s31 CHAR(31)
ESAC
);
SYN nul = C'00';
OutS: PROC(s String LOC); END OutS;
OutL: PROC(); END OutL;
OutC: PROC(c CHAR); END OutC;
OutI: PROC(i INT); END OutI;
END io;
beer: MODULE /* jr_31jan97 */
SEIZE String, nul, OutC, OutS, OutI, OutL <> USING io;
bottles: PROC(n INT, wall BOOL, end CHAR);
DCL s String;
IF n1 THEN OutI(n); s.s9:=' Bottles'//nul;
ELSIF n=1 THEN s.s11:='one Bottle'//nul;
ELSIF n=0 THEN s.s16:='no more Bottles'//nul;
FI;
OutS(s); s.s9:=' of Beer'//nul; OutS(s);
IF wall THEN s.s13:=' on the Wall'//nul; OutS(s); FI;
OutC(end); OutL();
END bottles;
singTheSong: PROC();
DCL i INT, s String;
DO FOR i:=99 DOWN TO 1;
bottles(i, TRUE, ',');
bottles(i, FALSE, '.');
s.s31:='Take one down, pass it around,'//nul; OutS(s); OutL();
bottles(i-1, TRUE, '.');
OD;
END singTheSong;
END beer;
Abundance
\ Abundance version of 99 bottles of beer
RG 2.0/1.0
<<<DEFINE 1 99 SMALL All-Bottles DEFINE>>>
<<< Bottles ( count -- ) DUP WRITE
CASE 0 OF DROP " No more bottles " ENDOF
1 OF DROP " 1 bottle "
ENDOF
OTHERS OF
. " bottles "
ENDOF ENDCASE >>>
<<< Sing
WRITE
<<<RFOR All-Bottles
I Bottles " of beer on the wall, "
I Bottles " of beer" NL
" Take one down and pass it around," NL
I 1- Bottles " of beer on the wall." 2 NLS
97/03/08
RFOR>>> >>>
A+
A+ is a hybrid of APL and C, developed primarily by Arthur Whitney amd Jeff Birnbaum,
and is used at the investment bank Morgan Stanley.
$mode uni
// Usage: fallsong n for "American" verison starting at n bottles.
//
takesong n for "British" version
//
eM n - general utility which returns english version of n.
// Note: Definition of billion, trillion, etc. follow American usage.
// Limits: Some counting and reporting problems caused by comparison
// tolerance and floating-point numbers above one trillion.
// Absolute limit: Approximately 9.9998354e65, at which point
// floating-point representation becomes unreliable.
ewd1:=("zero";"one";"two";"three";"four";"five";"six";"seven";"eight";"nin
e";
"ten";"eleven";"twelve";"thirteen";"fourteen";"fifteen";"sixteen";
"seventeen";"eighteen";"nineteen")
ewd10:=("";"";"twenty";"thirty";"forty";"fifty";"sixty";"seventy";
"eighty";"ninety"); ewdh:=" hundred"; ewdc:=" and ";
epow:=("";" thousand")," ",~("m";"b";"tr";"quadr";"quint";"sext";"sept";
"oct";"non";"dec";"undec";"duodec";"tredec";"quattuordec";"quindec";
"sexdec";"septendec";"octodec";"novemdec";"vigint"),~<"illion"
eH n:{if(20<=n){(t;xx):=0 10 M.>n;(t I.>ewd10),if(0=xx)""else "-",xx
I.>ewd1}
else n I.> ewd1}
eT n:{if(100<=n){(h;x):=0 100 M.>n;(h I.>ewd1),ewdh,if(0=x)""else ewdc,eH
x}
else eH n}
eM n:{z:="";(i:=#epow)do{
(n;x):=0 1000 M.>n;
if(0!=x)z:=,(((100>x)&(i=0)&0!=n)/"and "),(eT M.-x),(i I.>epow),
((0!=#z)/", "),z;
if(0=n):=z};z}
cap str:{n:=`int|1 S.+str;if((97<=n)&122>=n)str[0]:=`char|n- 32;str}
nb n:(if(0!=n)(cap eM n)else "No more"),((- 1=n)S.-" bottles")," of beer"
ootb n:if(1!=n)"one of those bottles"else"that bottle"
fate{b;n}:{if(b)".\nIf ",(ootb n)," should happen to fall,\n" else
".\nTake ",((1=n)I.>("one";"it"))," down; pass it around,\n"}
b stanza n:{w:=" on the wall.";
(nb n),w,"\n",(nb n),(b fate n),(nb n- 1),w,"\n"}
fallsong n:{(i:=n)do S.- 1 stanza n-i;}
takesong n:{(i:=n)do S.- 0 stanza n-i;}
Blank
This is a custom language project. The compiler is available at
http://www.sound.net/~aturley/blank.htm
99 Bottles of Beer
Written in Blank
by Andrew Turley
[99] bottles of beer
{#} pop the last calling cell
[20]{} call "x bottles of beer on the wall,"
[65]{} call "x bottles of beer."
[98]{} call "Take one down, pass it around,"
{:}[1]{-}{!}[7]{\}{|} if bottles of beer is not 1
[124]{} call "x-1 bottles of beer on the wall!"
{?}[19]{-}{} go back to the beginning of the program
[157]{} otherwise goto "No bottles of beer on the wall!"
"x bottles of beer on the wall," :36+11
{:}{.} print bottles of beer
[0] string termination
[10] "\n"
[44][108][108][97][119][32][101][104][116][32][110][111][32] ",llaw
eht no " [114][101][101][98][32][102][111][32] "reeb fo "
[24]{^}[1]{-}[4]{\}{!}{|} [115] "s" [1]{}{#}
[101][108][116][116][111][98][32] "elttob " [34]{} call the printing
part of the program {}{#}
[101][108][116][116][111][98][32] "elttob "
[34]{} call the printing part of the program
{} goto the
printing part of the program {} goto the
printing part of the program {}
goto the printing part of the program {@} exit program
printing part of the program :13
{:}[7]{\}{!}{|}{#}{,}{?}[10]{-}{} print the top of the stack until 0
{#} ppop the call {#} ppop the if {$} pop the 0 {
DAL
Apple's Data Access Language
/*
DAL version of 99 Bottles of beer programmer:
by Georg Hentsch: ghentsch@blsoft.com
*/
declare integer beers = 99;
declare varchar s;
while (beers 0)
{
if (beers != 1)
s = "s";
else
s = "";
printf("%d bottle%s of beer on the wall,\n", beers, s);
printf("%d bottle%s of beeeeer . . . ,\n", beers, s);
printf("Take one down, pass it around,\n");
beers--;
if (beers 0)
printf("%d", beers);
else
printf("No more");
if (beers != 1)
s = "s";
else
s = "";
printf(" bottle%s of beer on the wall.\n", s);
}
DOS Batch
@echo off
REM 99 Bottles of Beer in DOS Batch
REM Gert-jan Los (los@lsdb.bwl.uni-mannheim.de)
if "%1"=="" goto outer
if "%1"=="body" goto body
:inner
for %%a in ( 9 8 7 6 5 4 3 2 1 0 ) do call beer body %2 %%a
goto exit
:outer
for %%a in ( 9 8 7 6 5 4 3 2 1 0 ) do call beer inner %%a
goto exit
:body
set num=%2%3
set bottle=bottles
if "%num%"=="99" goto skipfirst
if "%2"=="0" set num=%3
if "%num%"=="1" set bottle=bottle
echo %num% %bottle% of beer on the wall
echo.
if "%num%"=="0" exit
:skipfirst
echo %num% %bottle% of beer on the wall
echo %num% %bottle% of beer
echo take one down and pass it around
:exit
Fortran
C
patrick m. ryan pryan@access.digex.net
program ninetynine
implicit none
integer i
do i=99,1,-1
print*, i,' bottles of beer on the wall, ',i,' bottles of beer'
print*, 'take one down, pass it around, ',i-1,
.
' bottles of beer on the wall'
enddo
end
Forth
\ Forth version of the 99 Bottles program.
\ Dan Reish, dreish@izzy.net
: .bottles ( n -- n-1 )
dup 1 = IF ." One bottle of beer on the wall," CR
." One bottle of beer," CR
." Take it down,"
ELSE dup . ." bottles of beer on the wall," CR
dup . ." bottles of beer," CR
." Take one down,"
THEN
CR
." Pass it around," CR
1?dup IF dup 1 = IF ." One bottle of beer on the wall;"
ELSE dup . ." bottles of beer on the wall;"
THEN
ELSE
THEN
CR
." No more bottles of beer on the wall."
;
: nbottles ( n -- )
BEGIN .bottles ?dup NOT UNTIL
;
99 nbottles
Fortran IV
C Allen Mcintosh
C mcintosh@bellcore.com
integer bottls
do 50 i = 1, 99
bottls = 100 - i
print 10, bottls
10
format(1x, i2, 31h bottle(s) of beer on the wall.)
print 20, bottls
20
format(1x, i2, 19h bottle(s) of beer.)
print 30
30
format(34h Take one down and pass it around,)
bottls = bottls - 1
print 10, bottls
print 40
40
format(1x)
50
continue
stop
end
Emacs Lisp
;;Geza Gyuk - gyuk@oddjob.uchicago.edu"
(defun beersong (n)
"Does the n-beers song."
(progn (insert (int-to-string n) " bottle" (cond ((= n 1) "")
(t "s"))
" of beer on the wall,\n")
(insert (int-to-string n) " bottle" (cond ((= n 1) "")
(t "s"))
" of beer,\n")
(insert "take one down and pass it around,\n")
(insert (cond ((= n 1) "no more")
(t (int-to-string (- n 1))))
" bottle" (cond ((= n 2) "")
(t "s"))
" of beer on the wall.\n\n")
(cond (( n 1) (beersong (- n 1))))))
hackMongo
hackMongo is an extension of the Mongo plotting package.
! Does the beer song... sends output to a postscript file
! Geza Gyuk - gyuk@oddjob.uchicago.edu
printer 1
erase
data beer.dat
setv rounds c1(1)
! get number of rounds
! from first line, first
! column of file beer.dat
setv container bottles
expand {5/rounds}
loop i {rounds} 2 -1
relocate 0.1 {i*5/(5*rounds)}
putlabel 6 {i} bottles of beer on the wall,
relocate 0.1 {(i*5-1)/(5*rounds)}
putlabel 6 {i} bottles of beer,
relocate 0.1 {(i*5-2)/(5*rounds)}
putlabel 6 take one down and pass it around,
if ({i}=2) setv container bottle
relocate 0.1 {(i*5-3)/(5*rounds)}
putlabel 6 {i-1} {container} of beer on the wall.
relocate 0.1 {(i*5-4)/(5*rounds)}
putlabel 6
endloop
relocate
putlabel
relocate
putlabel
relocate
putlabel
relocate
putlabel
hardcopy
end
0.1 {5/(5*rounds)}
6 1 bottle of beer on the wall,
0.1 {4/(5*rounds)}
6 1 bottle of beer,
0.1 {3/(5*rounds)}
6 take it down and pass it around,
0.1 {2/(5*rounds)}
6 no more bottles of beer on the wall.
Delphi
Note: Borland's Delphi only runs under Windows, so the simple task of dumping the text to
standard output isn't so simple any more. The large body of code is to account for the
Windows interface.
{----------------------------------------------------------------------}
{Contents of BEER99.DPR}
program Beer99;
{99 bottles of beer - Borland Delphi 1.0}
{by Rodney M. Savard <rodney.savard%phun@phunnet.org>}
uses
Forms,
Beer in 'BEER.PAS' {Form1};
{$R *.RES}
begin
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
{----------------------------------------------------------------------}
{Contents of BEER.PAS}
unit Beer;
interface
uses
Classes, Controls, Forms, StdCtrls, SysUtils;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Bottles: Integer;
s: String;
implementation
{$R *.DFM}
procedure TakeOneDown;
begin
with Form1 do begin
Memo1.Lines.Clear;
Memo1.Lines.Add(IntToStr(bottles)+' bottle'+s+' of beer on the
wall,');
Memo1.Lines.Add(IntToStr(bottles)+' bottle'+s+' of beer.');
Memo1.Lines.Add('');
Memo1.Lines.Add('Take one down, pass it around,');
Dec(Bottles);
if Bottles<>1 then s:='s' else s:='';
if Bottles=0 then begin
Memo1.Lines.Add('no more bottles of beer on the wall!');
Button1.Caption:='No More!';
Button1.Enabled:=False;
end
else begin
Memo1.Lines.Add(IntToStr(bottles)+' bottle'+s+' of beer on the
wall.');
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Bottles:=99;
s:='s';
Button1Click(Form1);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TakeOneDown;
end;
end.
{----------------------------------------------------------------------}
Dylan
// Dylan version of 99 Bottles of Beer
// programmer: Jim Studt jim@federated.com
define method enumerate( count == 1 ) "1 bottle" end method enumerate;
define method enumerate( count == 0 ) "no more bottles" end method
enumerate;
define method enumerate( count :: <integer> )
format-to-string("%d bottles", count);
end method enumerate;
define method reference( count == 1) "it" end method reference;
define method reference( count :: <integer>) "one" end method reference;
define method main (argv0, #rest noise)
for ( i from 99 to 1 by -1)
format( *standard-output*, "%s of beer on the wall, %s of beer.\n",
enumerate(i), enumerate(i));
format( *standard-output*,
" Take %s down, pass it around, %s of beer on the wall.\n",
reference(i), enumerate( i - 1));
end for;
end method main;
Eiffel
Click for information.
class BEERS
creation
make
feature
-- Creation
make is
local
i : INTEGER
b : STRING;
do
from i := 99 variant i until i <= 0 loop
if i = 1 then
b := " bottle";
else
b := " bottles"
end -- if
io.put_integer(i);
io.put_string(b);
io.put_string(" of beer on the wall, ");
io.put_integer(i);
io.put_string(b);
io.put_string(" of beer,");
io.new_line;
io.put_string("Take one down and pass it around, ");
i := i - 1;
io.put_integer(i);
io.put_string(b);
io.put_string(" bottles of beer on the wall.");
io.new_line;
end -- loop
io.put_string("Go to the store and buy some more,");
io.new_line;
io.put_string("99 bottles of beer on the wall.");
io.new_line;
end;
end -- class BEERS
Here is the OOP version of this in Eiffel... that is to say, the "proper" way to do Eiffel:
class SHELF
-- A shelf of bottles
creation
make
feature
make (l_bottles: INTEGER) is
require
positive_bottles: l_bottles = 0
do
bottles := l_bottles
end
remove is
require
bottles_exist: bottles 0
do
bottles := bottles - 1
ensure
removed: bottles = old bottles - 1
end
bottles: INTEGER
short_description: STRING is
do
if bottles = 0 then
Result := "No"
else
Result := bottles.out
end
Result.append (" bottle")
if bottles /= 1 then
Result.append ("s")
end
Result.append (" of beer")
ensure
result_exists: Result /= Void
end
description: STRING is
do
Result := short_description
Result.append (" on the wall, ")
Result.append (short_description)
Result.append ("%N")
ensure
result_exists: Result /= Void
end
empty: BOOLEAN is
do
Result := bottles = 0
end
invariant
positive_bottles: bottles = 0
end -- class SHELF
class BEER
-- Produuce the ditty
-- Nick Leaton
creation
make
feature
shelf: SHELF
make is
do
from
!!shelf.make (99)
until
shelf.empty
loop
io.put_string (shelf.description)
shelf.remove
io.put_string ("Take one down, pass it all around%N%N")
end
io.put_string (shelf.description)
io.put_string ("Go to the store and buy some more%N%N")
shelf.make (99)
io.put_string (shelf.description)
end
end -- class BEER
Erlang
Erlang is a language used for real-time control systems.
%
%
%
%
%
%
--------------------------------------------------------------Erlang version of the beer song
Kent Engström, kenen@ida.liu.se
--------------------------------------------------------------See http://www.ericsson.se/cslab/erlang/ for Erlang information
---------------------------------------------------------------
-module(beer).
-export([song/0]).
song() song(100).
song(0) done;
song(N) Bottles=bottles(N),
Bottles1=bottles(N-1),
io:format("~s of beer on the wall, ~s of beer.~n",
[Bottles,Bottles]),
io:format("Take one down and pass it around, ~s of beer on the
wall.~n",
[Bottles1]),
song(N-1).
bottles(0)"no more bottles";
bottles(1)"1 bottle";
bottles(N)lists:append(integer_to_list(N)," bottles").
Focal
01.10 c Focal-8 version of 99 Bottles of beer
01.20 c Hacked by Akira KIDA, <SDI00379@niftyserve.or.jp>
10.10 set bottles = 99
10.20 do 20
10.30 quit
20.10 for i = bottles, 1, -1; do 30
20.20 return
30.10
30.20
30.30
30.40
30.50
30.60
set b =
do 40 ;
do 40 ;
set b =
do 40 ;
return
i
type " on the wall, "
type ".", ! , "Take one down, pass it around.", !
i - 1
type " on the wall.", !, !
40.10 do 50
40.20 type " of beer"
40.30 return
50.10
50.20
50.30
50.40
50.50
50.60
50.70
if (b - 1) 50.20, 50.40, 50.60
type "No more bottles"
return
type %1.0, b, " bottle"
return
type %1.0, b, " bottles"
return
DECTPU
DEC's Pascal-like "Text Processing Utility."
PROCEDURE BEER
LOCAL BOTTLES, LINE_1, LINE_2, LINE_3;
BOTTLES := 99;
LINE_1 := "!SL bottle!%S of beer on the wall";
LINE_2 := "!SL bottle!%S of beer,";
LINE_3 := "If !0!1%Cthat single bottle"
+ "!%Eone of those bottles!%F should happen to fall,";
LOOP;
COPY_TEXT( FAO( LINE_1, BOTTLES) + ","); SPLIT_LINE;
COPY_TEXT( FAO( LINE_2, BOTTLES));
SPLIT_LINE;
COPY_TEXT( FAO( LINE_3, BOTTLES));
SPLIT_LINE;
BOTTLES := BOTTLES - 1;
COPY_TEXT( FAO( LINE_1, BOTTLES) + "."); SPLIT_LINE;
SPLIT_LINE;
EXITIF BOTTLES = 0;
ENDLOOP;
ENDPROCEDURE
False
The False language was created by Wouter van Oortmerssen (Wouter@alf.let.uva.nl).
{ False version of 99 Bottles by Marcus Comstedt (marcus@lysator.liu.se) }
[$0=["no more bottles"]?$1=["One bottle"]?$1[$." bottles"]?%" of beer"]b:
100[$0][$b;!" on the wall, "$b;!".
"1-"Take one down, pass it around, "$b;!" on the wall.
"]#%
Hope
Click for more information.
! Hope Version of 99 Bottles of Beer : RAM-Biter!!!
! Tested on a SPARC classic, SunSolaris 2
! Programmer: Wolfgang Lohmann
wlohmann@informatik.uni-rostock.de
dec
dec
dec
dec
app
i2c
i2s
beer
:( list
: num : num : num -
( char ) X list ( char )) - list ( char ) ;
char;
list(char);
list(char);
--- app ( nil , w )
<= w ;
--- app (( a :: v ), w )
<=( a :: app ( v , w )) ;
---------------------
i2c(0)
i2c(1)
i2c(2)
i2c(3)
i2c(4)
i2c(5)
i2c(6)
i2c(7)
i2c(8)
i2c(9)
<=
<=
<=
<=
<=
<=
<=
<=
<=
<=
'0';
'1';
'2';
'3';
'4';
'5';
'6';
'7';
'8';
'9';
--- i2s(x) <= if x < 10 then [i2c(x)] else
app(i2s(x div 10), i2s( x mod 10));
--- beer(x) <= if x = 1 then app( i2s(x),
" bottle of beer. No more beer on the wall.")
else app( app( app( app( app(
i2s(x),
" bottles of beer on the wall, "),
i2s(x)),
" bottles of beer. "),
"Take one down, pass it around. "),
beer(y))
where y== x-1;
Haskell
Click for more information.
-- Haskell program for the Beer Song.
--- Bert Thompson 5.11.95 (aet@cs.mu.oz.au)
module Main where
main = song 99
song n =
bob n ++ " on the wall,\n" ++
bob n ++ ".\n" ++
"Take one down, pass it around.\n" ++
if n == 1
then
"No more bottles of beer on the wall.\n"
else
bob (n-1) ++ " on the wall.\n"
++ song (n-1)
bob n =
show n ++ bottle ++ " of beer"
where
bottle = " bottle" ++ if n == 1 then "" else "s"
Fortran 90
!
!
!
F90 (Fortran 90) version of 99 bottles of beer.
written by Akira KIDA, SDI00379@niftyserver.or.jp
Note that this source is in FIXED format.
program ninetynine
implicit none
integer, parameter :: BOTTLES = 99
integer :: i
integer :: k
character*7 :: btl = 'bottles'
do i = BOTTLES, 1, -1
k = len(btl)
if (i == 1) k = k - 1
print *, i, btl(1:k), ' of beer on the wall, ',
c
i, btl(1:k), ' of beer.'
print *, 'Take one down, pass it around.'
if (i == 0) exit
print *, i, btl(1:k), ' of beer on the wall.'
end do
print *, 'No more bottles of beer on the wall.'
end
Forms/3
Programming in Forms/3 follows the spreadsheet paradigm; the programmer uses direct
manipulation to place cells on forms, and then defines a formula for each cell. Click here for
more information.
DIBOL
.TITLE - "Program to display 99 bottles of beer on the wall"
;
;=========================================================================
==============================
;
Author: Bob Welton (welton@pui.com)
;
Projects Unlimited Inc.
;
Dayton, OH 45414
;
;
Language: DIBOL or DBL
;=========================================================================
==============================
RECORD MISC
NUMBOTTLES
ANUMBOTTLES
bottles
,D2,99
,A2
;Default # of bottles to 99
;Used to mask the output of
.PROC
XCALL FLAGS (0007000000,1)
;Suppress STOP message
OPEN (8,O:C,"TT:")
;Open the terminal/display
REPEAT
BEGIN
ANUMBOTTLES = NUMBOTTLES,'ZX'
WRITES (8,ANUMBOTTLES+" Bottles of Beer on the wall,")
ANUMBOTTLES = NUMBOTTLES,'ZX'
WRITES (8,ANUMBOTTLES+" Bottles of Beer,")
WRITES (8,"
Take one down, pass it around,")
DECR NUMBOTTLES
;Reduce # of bottles by 1
IF (NUMBOTTLES .LE. 1) EXITLOOP ;If just 1 bottle left, get out
ANUMBOTTLES = NUMBOTTLES,'ZX'
WRITES(8,ANUMBOTTLES+" Bottles of Beer on the wall.")
WRITES (8," ")
END
ANUMBOTTLES = NUMBOTTLES,'ZX'
WRITES(8,ANUMBOTTLES+" Bottle of Beer on the wall.")
WRITES (8," ")
WRITES (8,ANUMBOTTLES+" Bottle of Beer on the wall,")
WRITES (8,ANUMBOTTLES+" Bottle of Beer,")
WRITES (8,"
Take one down, pass it around,")
WRITES (8," ")
WRITES (8," ")
WRITES (8, "Hey the Beer's gone, I am out of here...")
SLEEP 2
CLOSE 8
STOP
.END
dBase III
&& BEER.PRG - 99 Bottles of Beer - Brian Hobbs Jan 1996
&& (BHOBBS@cayman.vf.mmc.com)
SET TALK OFF
I=99
DO WHILE I=1
b = STR(i,2)
? b +" Bottle"
IF i > 1
?? "s"
ENDIF
?? " of beer on the wall "+b+" bottle"
IF i 1
?? "s"
ENDIF
?? " of beer"
? "
Take one down and pass it around"
i=i-1
b = STR(i,2)
if i = 0
b = "No more"
ENDIF
? b + " Bottle"
IF I > 1 .OR. I=0
?? "s"
ENDIF
?? " of beer on the wall"
?
ENDDO
? "No more bottles of beer on the wall, No more bottles of beer"
? "Go to the store and buy some more - 99 bottles of beer on the wall"
SET TALK ON
Gofer
Gofer is a variation of Haskell. More Information
-- 99 bottles of beer (gofer version)
-- Written by Bow-Yaw Wang (bywang@saul.cis.upenn.edu)
radix 0 _ = []
radix x n = (x `mod` n):(radix (x/n) n)
itoa x = map (\x - chr(x + ord('0'))) (reverse (radix x 10))
bottles :: Int - Dialogue
bottles 1 resps = [AppendChan stdout "1 bottle of beer on the wall, ",
AppendChan stdout "1 bottle of beer.\n",
AppendChan stdout "Take one down, pass it around, ",
AppendChan stdout "no more bottles of beer on the
wall.\n"]
bottles n resps = [AppendChan stdout (itoa n),
AppendChan stdout " bottles of beer on the wall, ",
AppendChan stdout (itoa n),
AppendChan stdout " bottles of beer.\n",
AppendChan stdout "Take one down, pass it around, ",
AppendChan stdout (itoa (n-1)),
AppendChan stdout " bottles of beer on the wall.\n"] ++
bottles (n-1) resps
Dialog System
'Dialog System', a system for developing graphical applications.
# Programmer: Mark Gray - mvg@mfltd.co.uk
# http://www.mfltd.co.uk/
#
# Note: requires version 2.5 of Dialog System.
Form BEER
Screenset Details
First-Window WIN1
End Details
Form Data
Group BOTTLE-TEXT-GROUP-1 Vertical Occurs 1
NUMBER-OF-BOTTLES-1 Integer(2)
BOTTLE-TEXT-1 Character(28)
BOTTLE-PUNCTUATION-1 Character(1)
End Group # BOTTLE-TEXT-GROUP-1
Group BOTTLE-TEXT-GROUP-2 Vertical Occurs 1
NUMBER-OF-BOTTLES-2 Integer(2)
BOTTLE-TEXT-2 Character(17)
End Group # BOTTLE-TEXT-GROUP-2
BOTTLE-TEXT-1A Character(31)
BOTTLE-TEXT-2A Character(19)
BOTTLE-TEXT-3 Character(30)
BOTTLE-TEXT-4 Character(34)
End Data
Object WIN1
Type DIALOG-BOX
Parent DESKTOP
Start (492,720)
Size (1208,1150)
Display "99 Bottles of Beer"
Style MODELESS TITLEBAR SYSTEM-MENU
End Object #WIN1
Object BEER-LIST
Type LIST-BOX
Parent WIN1
Start (64,100)
Size (1088,800)
Style DISABLE-HORIZONTAL
End Object #BEER-LIST
Object PB1
Type PUSH-BUTTON
Parent WIN1
Start (416,1040)
Size (372,96)
Display "Close"
End Object #PB1
Global Dialog CASE(OFF)
Event ESC
SET-EXIT-FLAG ;
TERMINATE ;
End Event # ESC
Event CLOSED-WINDOW
SET-EXIT-FLAG ;
TERMINATE ;
End Event # CLOSED-WINDOW
Event BUTTON-SELECTED
SET-EXIT-FLAG ;
TERMINATE ;
End Event # BUTTON-SELECTED
Event SCREENSET-INITIALIZED
MOVE " bottles of beer on the wall" BOTTLE-TEXT-1(1) ;
MOVE " bottles of beer," BOTTLE-TEXT-2(1) ;
MOVE "Take one down, pass it around," BOTTLE-TEXT-3 ;
MOVE "Go to the store and buy some more," BOTTLE-TEXT-4 ;
MOVE 99 NUMBER-OF-BOTTLES-1(1) ;
BRANCH-TO-PROCEDURE COUNT-BOTTLES ;
End Event # SCREENSET-INITIALIZED
Procedure COUNT-BOTTLES
MOVE NUMBER-OF-BOTTLES-1(1) NUMBER-OF-BOTTLES-2(1) ;
MOVE "," BOTTLE-PUNCTUATION-1(1) ;
MOVE BOTTLE-TEXT-GROUP-1 BOTTLE-TEXT-1A ;
MOVE BOTTLE-TEXT-GROUP-2 BOTTLE-TEXT-2A ;
INSERT-LIST-ITEM BEER-LIST BOTTLE-TEXT-1A 0 ;
INSERT-LIST-ITEM BEER-LIST BOTTLE-TEXT-2A 0 ;
MOVE "." BOTTLE-PUNCTUATION-1(1) ;
IF= NUMBER-OF-BOTTLES-1(1) 0 END-BOTTLES ;
INSERT-LIST-ITEM BEER-LIST BOTTLE-TEXT-3 0 ;
DECREMENT NUMBER-OF-BOTTLES-1(1) ;
MOVE BOTTLE-TEXT-GROUP-1 BOTTLE-TEXT-1A ;
INSERT-LIST-ITEM BEER-LIST BOTTLE-TEXT-1A 0 ;
BRANCH-TO-PROCEDURE COUNT-BOTTLES ;
End Procedure # COUNT-BOTTLES
Procedure END-BOTTLES
MOVE 99 NUMBER-OF-BOTTLES-1(1) ;
MOVE BOTTLE-TEXT-GROUP-1 BOTTLE-TEXT-1A ;
INSERT-LIST-ITEM BEER-LIST BOTTLE-TEXT-4 0 ;
INSERT-LIST-ITEM BEER-LIST BOTTLE-TEXT-1A 0 ;
End Procedure # END-BOTTLES
End Dialog
End Form
HyperTalk
The scripting language for Apple's HyperCard.
--- a version of the "99 bottles of beer" song in HyperTalk
-- by eric carlson: eric@bungdabba.com
-on BeerSong99
BottlesOfBeer 99
end BeerSong99
--- do something with a lyric from the beer song.
it to
-- a field on the current card
on OutputBeerLyric beerString
if ( beerString is "<reset>" ) then
put empty into cd fld "beer song"
this handler adds
else
put beerString & return after cd fld "beer song"
end if
end OutputBeerLyric
--- sing the beer song with the specified number of bottles
on BottlesOfBeer bottleCount
put bottleCount into initialCount
OutputBeerLyric "<reset>"
repeat until ( bottleCount < 1 )
set cursor to busy
-- let 'em know this might take a while
put BottleString(bottleCount) into currentString
OutputBeerLyric currentString && "of beer on the wall,"
OutputBeerLyric currentString && "of beer."
OutputBeerLyric "Take one down, and pass it around,"
subtract one from bottleCount
OutputBeerLyric BottleString(bottleCount) && "of beer on the
wall." & return
end repeat
OutputBeerLyric "Go to the store and buy some more..."
OutputBeerLyric initialCount & " bottles of beer on the wall."
end BottlesOfBeer
--- return the bottle string appropriate for the current count
function BottleString bottleCount
if ( bottleCount is 1 ) then
return "1 bottle"
else if ( bottleCount is 0 ) then
return "no more bottles"
else
return bottleCount && "bottles"
end if
end BottleString
Foxpro/Xbase
The scripting language controlling the Foxpro database.
** Randy Jean
FOR x = 100 TO 1 STEP -1
?x,"Bottle(s) of beer on the wall,",x,"bottle(s) of beer"
?"
Take one down and pass it around,"
?x-1,"bottle(s) of beer on the wall"
ENDFOR
Froth
\ 99 bottles of beer in Froth, by Leo Wong, a teetotaler
\ Pass it around.
: LYRICS
[CHAR] ! PARSE TUCK HERE CHAR+
CHARS ALLOT ;
: VOCALIZE ( a) COUNT TYPE ;
: SING
CREATE LYRICS DOES VOCALIZE ;
SING
SING
SING
SING
SING
SING
SING
SING
SING
SING
SING
SING
6FEB96
SWAP CHARS MOVE
+
DUP C,
NO_MORE No more !
BOTTLE bottle!
BOTTLES bottles!
OF_BEER of beer!
ON_THE_WALL on the wall!
TAKE Take !
IT it!
ONE one!
DOWN_AND_PASS_IT_AROUND down and pass it around!
GO_TO_THE_STORE_&_BUY_SOME_MORE Go to the store and buy some more!
COMMA ,!
PERIOD .!
: ?: CREATE ( n) ,
' , ' ,
DOES ( n) TUCK @ <> 1- CELLS : NONE
: SOME
( n)
( n)
DROP NO_MORE ;
. ;
0 ?: HOW_MANY
NONE
1 ?: BOTTLE(S)
1 ?: IT|ONE
@ EXECUTE ;
IT
SOME
BOTTLE
BOTTLES
ONE
: COMMERCIAL ( 0 - 99)
: SHAREWARE ( n - n-1)
;
0 ?: main(){0?99:--}
GO_TO_THE_STORE_&_BUY_SOME_MORE 99 + ;
DUP TAKE IT|ONE DOWN_AND_PASS_IT_AROUND
COMMERCIAL
: BURP ( n - n n) DUP ;
: HOW_MANY_BOTTLES_OF_BEER
: Froth ( n - n')
CR BURP BURP BURP
CR BURP BURP BURP
CR BURP
CR BURP BURP BURP
CR ;
SHAREWARE
( n n n)
HOW_MANY BOTTLE(S) OF_BEER ;
HOW_MANY_BOTTLES_OF_BEER ON_THE_WALL
HOW_MANY_BOTTLES_OF_BEER
main(){0?99:--}
HOW_MANY_BOTTLES_OF_BEER ON_THE_WALL
COMMA
COMMA
COMMA
PERIOD
1-
: LeoWong
: SONG
( n)
DROP ;
99
Draco
An Amiga language combining features of C and Pascal
/* 99 Bottles of Beer */
/* James Hicks (hicksjl@cs.rose-hulman.edu) */
/* 5 August 1996 */
int BEERS = 99;
proc main()void:
uint i;
for i from BEERS downto 1 do
if i > 1 then
writeln(i, " bottles of beer on the wall, ", i, " bottles of
beer.");
else
writeln(i, " bottle of beer on the wall, ", i, " bottle of beer.");
fi;
writeln("Take one down, pass it around,");
if i > 2 then
writeln(i - 1, " bottles of beer on the wall.");
elsif i > 1 then
writeln(i - 1, " bottle of beer on the wall.");
else
writeln("No bottles of beer on the wall.");
fi;
od;
corp;
Expect
Update: Through some kind comments from others, I can now say something about this
language. It is designed to talk to other interactive programs apparently for testing purposes.
I am told the contributor was the author of the language but apparently was being humble.
#!/usr/local/bin/expect
# 99 bottles of beer on the wall, Expect-style
# Author: Don Libes
#
#
#
#
#
#
Unlike programs (http://www.ionet.net/~timtroyr/funhouse/beer.html)
which merely print out the 99 verses, this one SIMULATES a human
typing the beer song. Like a real human, typing mistakes and timing
becomes more erratic with each beer - the final verse is barely
recognizable and it is really like watching a typist hunt and peck
while drunk.
# Finally, no humans actually sing all 99 verses - particularly when
# drunk. In reality, they occasionally lose their place (or just get
# bored) and skip verses, so this program does likewise.
#
#
#
#
#
Because the output is timed, just looking at the output isn't enough
- you really have to see the program running to appreciate it.
Nonetheless, for convenience, output from one run (it's different
every time of course) can be found in the file beer.exp.out
But it won't show the erratic timing; you have to run it for that.
proc bottles {i} {
return "$i bottle[expr $i!=1?"s":""] of beer"
}
proc line123 {i} {
out $i "[bottles $i] on the wall,\n"
out $i "[bottles $i],\n"
out $i "take one down, pass it around,\n"
}
proc line4 {i} {
out $i "[bottles $i] on the wall.\n\n"
}
proc out {i s} {
foreach c [split $s ""] {
# don't touch punctuation; just looks too strange if you do
if [regexp "\[,. \n\]" $c] {
append d $c
continue
}
# keep first couple of verses straight
if {$i > 97} {append d $c; continue}
# +3 prevents it from degenerating too far
# /2 makes it degenerate faster though
set r [rand [expr $i/2+3]]
if {$r} {append d $c; continue}
# do something strange
switch [rand 3] {
0 {
# substitute another letter
if [regexp \[aeiou\] $c] {
# if vowel, substitute another
append d [string index aeiou [rand 5]]
} elseif [regexp \[0-9\] $c] {
# if number, substitute another
append d [string index 123456789 [rand 9]]
} else {
# if consonant, substitute another
append d [string index bcdfghjklmnpqrstvwxyz
[rand 21]]
}
} 1 {
# duplicate a letter
append d $c$c
} 2 {
# drop a letter
}
}
}
set
set
set
set
set
arr1 [expr .4 - ($i/333.)]
arr2 [expr .6 - ($i/333.)]
shape [expr log(($i+2)/2.)+.1]
min 0
max [expr 6-$i/20.]
set send_human "$arr1 $arr2 $shape $min $max"
send -h $d
}
set _ran [pid]
proc rand {m} {
global _ran
set period 259200
set _ran [expr ($_ran*7141 + 54773) % $period]
expr int($m*($_ran/double($period)))
}
for {set i 99} {$i0} {} {
line123 $i
incr i -1
line4 $i
# get bored and skip ahead
if {$i == 92} {
set i [expr 52+[rand 5]]
}
if {$i == 51} {
set i [expr 12+[rand 5]]
}
if {$i == 10} {
set i [expr 6+[rand 3]]
}
}
Sample output:
99 bottles of beer on the wall,
99 bottles of beer,
take one down, pass it around,
98 bottles of beer on the wall.
11 botqle off baer oc tbe wakl,
1 botplo of beer,
take onne da, pass itt arounm,
0 yotglees oof beeeer on tte walll.
FileMaker Pro 3.0
This program will allegedly sing to you. Program courtesy Jon Rosen
(techwiz@netaxis.com).
Enter Browse Mode
Set Field No. Bottles/Calculation (99)
Set Field Bottle Text/Calculation (³²)
Loop
Set Field Bottle Text/Calculation
If(No. Bottles ‚ 1,
No. Bottles & ³bottles of beer on the wall. ³ & No. Bottles &
³bottles of beer.² & Paragraph & ³Take one down and pass it around and ³,
No. Bottles & ³bottle of beer on the wall. ³ & No. Bottles & ³bottle
of beer.² & Paragraph & ³Take one down and pass it around and ³) &
Paragraph &
If(No. Bottles - 1 ‚ 1,
(No. Bottles - 1) & ³ bottles of beer on the wall²,
(No. Bottles - 1) & ³ bottle of beer on the wall²)
Refresh Window
Comment (Viewing text is optional)
Speak (Speech Data: Field: Bottle Text/Wait for completion)
Comment (Speech is optional)
Set Field No. Bottles/Calculation (No. Bottles - 1)
Exit Loop If (Calculation (No. Bottles = 0))
End Loop
Set Field Bottle Text/Calculation (³0 bottles of beer on the wall. 0
bottles of beer. Go to the store and buy some more.² & Paragraph & ³99
bottles of beer on the wall.²
Refresh Window
Speak (Speech Data: Field: Bottle Text/Wait for completion)
GrASP
GrASP is used for controlling the GrASP animation program.
video 1
local var1 99
local var2 24
mark 98
text 1 @var2 @var1
text " bottle(s) of beer on the wall,"
text 1 @var2-1 @var1
text " bottle(s) of beer!"
text 1 @var2-2 "Take one down, pass it around,"
text 1 @var2-3 @var1-1
text " bottle(s) of beer on the wall!"
waitkey 500
set var1 @var1-1
loop
GNU-cpp
/************************************************************************/
/*
bottle.cpp
*/
/*
1996 Walter Zimmer (walter.zimmer@rz.uni-ulm.de)
*/
/*
*/
/*
Save as "bottle.cpp" or change all the #includes !
*/
/*
#include is necessary since cpp expands each line into
*/
/*
no more than one new line
*/
/*
*/
/*
Invocation: cpp -P bottle.cpp
*/
/*
*/
/*
Remove comments to have less empty lines in the output
*/
/*
but we still have to many...
*/
/************************************************************************/
#if defined TEXT
/* This is the part which outputs one verse. 'Passed' parameters are */
/* ONES:
inner digit */
/* TENS:
outer digit */
/* SECONDTEN:
outer digit decremented by one */
/* if ONES == 0 then we have to use the decremented outer digit */
#if ONES == 0
/* omit output of 00 verse */
#if SECONDTEN
EXEC
* EXEC version of 99 Bottles of beer program
* By Torbjørn Vaaje (etotv@eto.ericsson.se)
*
&BEERS = 99
&S = ES
&LOOP 5 99
&TYPE &BEERS BOTTL&S OF BEER ON THE WALL, &BEERS BOTTL&S OF BEER.
&BEERS = &BEERS - 1
&IF &BEERS = 1 &S = E
&IF &BEERS = 0 &BEERS = NO_MORE
&TYPE TAKE ONE DOWN AND PASS IT AROUND, &BEERS BOTTL&S OF BEER ON THE WALL
Focus
Focus is a fourth generation data reporting/management language/toolset. It runs on a
numerous platforms, from Windows up to MVS. http://www.ibi.com/
-* Randy Gleason
-* 99 beer challenge
-REPEAT ENDBEER FOR &COUNTER FROM 99 TO 1 STEP -1
-SET &PL = IF &COUNTER EQ 1 THEN '' ELSE 's' ;
-TYPE &COUNTER bottle&PL of beer on the wall, &COUNTER bottle&PL of beer
-TYPE Take one down, pass it around
-TYPE
-ENDBEER
-TYPE No more bottles of beer on the wall, No more bottles of beer
-TYPE And we all shout out..WHO'S BUYING THE NEXT ROUND!
Express
Custom language used by IRI Software
"
"
"
Language: Express
Written by Lori Smallwood, IRI Software
April 12, 1997
vrb _beer int
_beer = 99
while _beer gt 0
do
shw joinchars(_beer ' bottles of beer on the wall,')
shw joinchars(_beer ' bottles of beer... ')
shw 'Take one down, pass it around,'
_beer = _beer - 1
shw joinchars(_beer ' bottles of beer on the wall!')
doend
Excel
Admittedly, yet another VB application.
Sub Beers()
' 99 bottles of beer on the wall
' Visual Basic for Excel version
' by Alejandro Julien (ajulien@tonatiuh.sis.uia.mx)
' Done with Excel 7 (Windows '95)
'
' It will start from the first cell of the first worksheet
' and move on downwards.
Dim Cervezas As Integer 'Cervezas = beer in spanish
Dim miCelda As Integer 'miCelda = myCell in spanish
Worksheets(1).Activate
' Colors
Range("A1:AA1").Interior.Color = RGB(0, 0, 128)
ActiveCell.Offset(1, 0).Value = "by Alejandro Julien"
Range("A1:A204").Font.Color = RGB(0, 0, 128)
' Title
Range("A1").Select
With ActiveCell
.Value = "The 99 bottles of beer on the wall song"
.Font.Size = 18
.Font.Color = RGB(255, 255, 255)
End With
With ActiveCell.Offset(2, 0)
.Value = "(ajulien@tonatiuh.sis.uia.mx)"
With .Font
.Italic = True
.Size = 8
End With
End With
miCelda = 3
' GO!
For Cervezas = 99 To 2 Step -1
ActiveCell.Offset(miCelda, 0).Value = Cervezas & " bottles of beer
on the wall, " & Cervezas & " bottles of beer"
miCelda = miCelda + 1
ActiveCell.Offset(miCelda, 0).Value = "take one down and pass it
around"
miCelda = miCelda + 1
Next
' ONE_BEER_EXCEPTION handling *whew!*
ActiveCell.Offset(miCelda, 0).Value = "One bottle of beer on the wall,
one bottle of beer"
miCelda = miCelda + 1
ActiveCell.Offset(miCelda, 0).Value = "take it down and pass it
around"
miCelda = miCelda + 1
' Beer's over
ActiveCell.Offset(miCelda, 0).Value = "No more bottles of beer on the
wall, no more bottles of beer"
miCelda = miCelda + 1
ActiveCell.Offset(miCelda, 0).Value = "Go to the store and buy some
more"
miCelda = miCelda + 1
' Sponsor's message
With ActiveCell.Offset(miCelda, 0)
.Value = "...but make sure it's mexican beer!"
.Font.Italic = True
.Font.Size = 8
End With
Application.Caption = "Cerveza mexicana siempre!"
' No kidding. If you have the chance, try a good mexican beer (:
'------' This piece of code goes for the "99 bottles of beer" homepage,
' and may be used by whoever finds it useful to show Language,
' way of doing the chore, or proof that programmers seem to have
' no life (even though this is not a complete truth...)
' <#include "disclaim.h
End Sub
dc
dc is the Desk Calculator for *nix; It works on reverse polish notation, and a few other
commands. The output of this routine is a little jagged, as dc has no commands to control
screen formatting.
Usage: dc 99bottles
where this source file is saved as 99bottles NB: A blank line is required at the end of the file
Without it, dc will not quit.
[
bottles of beer on the wall
]sa
[
bottles of beer
]sb
[
take one down, pass it around
]sc
[
]sd
99sn
[lalnpsnPlblnp1-snPlcPlalnpsnPldPln0
dc
dc is the Desk Calculator for *nix; It works on reverse polish notation, and a few other
commands. The output of this routine is a little jagged, as dc has no commands to control
screen formatting.
Usage: dc 99bottles
where this source file is saved as 99bottles NB: A blank line is required at the end of the file
Without it, dc will not quit.
[
bottles of beer on the wall
]sa
[
bottles of beer
]sb
[
take one down, pass it around
]sc
[
]sd
99sn
[lalnpsnPlblnp1-snPlcPlalnpsnPldPln0
E
E is the macro language for IBM's EPM editor.
;
-/*
*
*
99 bottles of beer in E, the macro language for IBM's EPM editor.
Todd Fox
The most interesting thing about this language is that it has 3
different commenting styles and that the macros must be recompiled
directly into the editor to be used. */
defproc make_bottle_text(num_bottles)
if (num_bottles 1) then
bottle_text = num_bottles || ' bottles'
elseif (num_bottles = 1) then
bottle_text = num_bottles || ' bottle'
else
bottle_text = 'No bottles'
endif
return(bottle_text)
defproc sing_beer_main_line(num_bottles, is_long)
lyrics = make_bottle_text(num_bottles) || ' of beer'
if (is_long) then
lyrics = lyrics || ' on the wall'
endif
insertline lyrics
defproc sing_beer_song()
init_bottle_cnt = 99
curr_bottle_cnt = init_bottle_cnt
do while curr_bottle_cnt = 1
sing_beer_main_line(curr_bottle_cnt, 1)
sing_beer_main_line(curr_bottle_cnt, 0)
insertline 'Take one down and pass it around'
curr_bottle_cnt = curr_bottle_cnt - 1
sing_beer_main_line(curr_bottle_cnt, 1)
insertline '' -- don't use "insert", existing text will get mixed
in
enddo
sing_beer_main_line(curr_bottle_cnt, 1)
sing_beer_main_line(curr_bottle_cnt, 0)
insertline 'Go to the store and buy some more'
curr_bottle_cnt = init_bottle_cnt
sing_beer_main_line(curr_bottle_cnt, 1)
; Define a command to execute it from the EPM command line.
defc sing_beer_song
call sing_beer_song()
; Execute with ctrl-X
def c_X = 'sing_beer_song'
; done
DSSP
For Info see http://www.dssp.msk.ru
[
99 bottles in DSSP
Programmer: Laszlo Aszalos <aszalos@math.klte.hu>
Run it with 99 BOTTLE
]
B10
: BOTTLE [N] LOT_OF ONE_LEFT ZERO [] ;
: LOT_OF [N] CR C 1- DO ONE_BOTTLE D ;
: ONE_BOTTLE [N]
ON_THE_WALL .", " CR NUMBER_OFF BOTTLES ."," CR
TAKE 1- [N-1] C 1 = IF0 MANY ;
:
:
:
:
MANY ON_THE_WALL ."." CR ;
TAKE ."take one down, pass it around," CR ;
ON_THE_WALL NUMBER_OFF BOTTLES ." on the wall" ;
BOTTLES ." bottles of beer" ;
: ONE_LEFT ONE_ON_THE_WALL ."." CR ONE_ON_THE_WALL ."," CR BOTTLE1
."," CR ;
: ONE_ON_THE_WALL BOTTLE1 ." on the wall" ;
: BOTTLE1 ." 1 bottle of beer" ;
: ZERO TAKE ZERO_ON ."." CR ZERO_ON ."," CR NO_MORE ."," CR
."go to the store, and buy some more!" CR ;
: ZERO_ON NO_MORE ." on the wall" ;
: NO_MORE ."no more bottles of beer" ;
: NUMBER_OFF C 2 TON ;
: NUMBER_OFF C 2 TON ;
Compilation Copyright 1995, 1996, 1997 Tim Robinson. All Rights Reserved
Permission to copy enthusiastically granted to instructors of computer science
(who would like to demonstrate the styles of different programming languages
to their students) provided that the names of the contributors are retained.
More beer
Back to the Funhouse
Macintosh WordPerfect
; Here is the Macintosh WordPerfect macro language version.
Assign (Var01;99)
Repeat
Type Var (Var01)
Type ( bottles of beer on the wall. )
Type Var (Var01)
Type ( bottles of beer. )
Type (Take one down, pass it around. )
Assign (Var01;Var01-1)
Type Var (Var01)
Type ( bottles of beer on the wall.)
Hard Return
Until (Var01=0)
Modula 2
(* Modula-2 version of 99 Bottles of Beer
*)
(* Tested on a VAX 7700 running OpenVMS
*)
(* Programmer: Jeremy Rule rulej@tempest.adsnet.net *)
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.
Modula 3
MODULE BottlesOfBeer EXPORTS Main;
FROM IO IMPORT Put ;
FROM Fmt IMPORT Int ;
VAR bottles := 99 ;
BEGIN
WHILE (bottles > 0) DO
Put(Int(bottles) & " bottle(s) of beer on the wall,\n") ;
Put(Int(bottles) & " bottle(s) of beer. \n") ;
Put("Take one down, and pass it around,\n");
DEC(bottles);
Put(Int(bottles) & " bottle(s) of beer on the wall.\n");
END ;
END BottlesOfBeer.
LPC
LPC was originally conceived as a object oriented C-like language for writing MUDs and
being able to modify them on the fly.
// beersong.c
// an implementation in the LPC language
// Tim Hollebeek, 6/6/95 - tim@debusy.Princeton.EDU
private string bottles(int n) {
switch (n) {
case 0: return "no more bottles of beer";
case 1: return "1 bottle of beer";
default: return n + " bottles of beer";
}
}
void beersong() {
for (int i = 99; i; i--) {
write(bottles(i) + " on the wall, " + bottles(i)
+ ", take one down, pass it around, "
+ bottles(i - 1) + " on the wall.\n");
}
}
Mumps
; The following is a single line of code
beer
; Randy M. Hayman (haymanr@icefog.alaska.edu)
for i=99:-1:1 w !,i," bottle",$S(i=1:"",1:"s")," of beer on the wa
ll, ",i," bottle",$S(i=1:"",1:"s")," of beer.",!,"Take one down, pass it a
round, ",i-1," bottle",$S(i=2:"",1:"s")," of beer on the wall.",!
ITCL
#!/usr/local/bin/itcl_sh
# [incr Tcl] version of "99 bottles of beer"
# Author: Steven Grady
# grady@xcf.berkeley.edu
itcl_class bottle {
constructor {config} {
incr numBottles
}
destructor {
incr numBottles -1
}
method drink {} {
puts "Take one down, pass it around,"
$this delete
}
proc numBottleStr {} {
switch $numBottles {
0 {
return "No more bottles of beer"
}
1 {
return "1 bottle of beer"
}
default {
return "$numBottles bottles of beer"
}
}
}
proc numBottles {} {
return $numBottles
}
common numBottles 0
}
proc createBottles {numBottles} {
for {set i 0} {$i < $numBottles} {incr i} {
bottle #auto
}
}
createBottles 99
foreach b [itcl_info objects -class bottle] {
set str [bottle :: numBottleStr]
puts "$str on the wall, $str"
$b drink
puts "[bottle :: numBottleStr] on the wall."
}
M4
A Unix macro language.
# by Ozan S. Yigit" (oz@sni.ca)
#
define(BOTTLES,`ifelse($1, 0, no more bottles,
$1, 1, one bottle, $1 bottles) of beer') dnl
define(BEER,`ifelse(eval($1 > 0), 1,
`BOTTLES($1) on the wall, BOTTLES($1)
take one down, pass it around
BOTTLES(eval($1 - 1)) on the wall.
BEER(eval($1 - 1))')') dnl
BEER(10)
Java
Java is a machine independent compiler based on C++ which targets to pseudo-code.
// java version of 99 bottles of beer on the wall
// 1995 Sean Russell (ser@cs.uoregon.edu)
class bottles
{
public static void main(String args[])
{
String s = "s";
for (int beers=99; beers-1;)
{
System.out.print(beers + " bottle" + s + " of beer on the wall, ");
System.out.println(beers + " bottle" + s + " of beer, ");
if (beers==0)
{
System.out.print("Go to the store, buy some more, ");
System.out.println("99 bottles of beer on the wall.\n");
System.exit(0);
}
else
System.out.print("Take one down, pass it around, ");
s = (--beers == 1)?"":"s";
System.out.println(beers + " bottle" + s + " of beer on the
wall.\n");
}
}
}
Java Script
Interpretive Java.
/**
* 99 Bottles of Beer on the Wall in JavaScript
* This program prints out the lyrics of an old pub song.
* Copyright (C) 1996, Brian Patrick Lee (blee@media-lab.mit.edu)
*/
if (confirm("Are you old enough to read about beer\n" +
"according to your local community standards?")) {
for (i = 99 ; i > 0 ; i--) {
j = i - 1;
if (i != 1) {
icase = "bottles";
} else {
icase = "bottle";
}
if (j != 1) {
jcase = "bottles";
} else {
jcase = "bottle";
}
document.writeln(i + " " + icase + " of beer on the wall,");
document.writeln(i + " " + icase + " of beer,");
document.writeln("Take 1 down, pass it around,");
if (j != 0) {
document.writeln(j + " " + jcase + " of beer on the wall.");
} else {
document.writeln("No more bottles of beer on the wall!");
}
document.writeln()
}
} else {
document.write("You might want think about moving to another
community.")
}
INTERCAL
INTERCAL is a real language, apparently created with the notion that programming ought
to be hard. Program courtesy Matt Dimeo.
PLEASE DO ,10
Icon
# Scott E Gilbert <scott@cs.arizona.edu>
procedure main()
t:= table("bottles")
t[1]:= "bottle"
every n:= 100 to 1 by -1 do {
write(n, " ", t[n], " of beer on the wall.\n",
n, " ", t[n], " of beer.\n",
"Take one down, Pass it around.\n",
n-1, " ", t[n-1], " of beer on the wall.\n"
)
}
end
MATLAB
Click for more information.
% MATLAB verion of 99 Bottles of beer
% by Bill Becker
function beer(n);
if nargin<1, n=99; end
for i=n:-1:1,
disp([int2str(i) ' Bottles of beer on the wall,'])
disp([int2str(i) ' Bottles of beer,'])
disp('Take one down and pass it around,')
if i1, disp([int2str(i-1) ' Bottles of beer on the wall.']),end
end
disp('No more bottles of beer on the wall!')
Here is a version contributed that shows the language in its more "native" form. (Cf. C++)
% MATLAB *vectorized* version of "99 bottles of beer"
% Rich Stein (rich@cs.umbc.edu)
bottles = [98:-1:3]; % bottles 98 to 3 (99, 2 & 1 are treated as special
case)
lines = 3; % need the number of bottles at the beginning of 3 lines
num_array = ones(lines,1) * bottles; % bottles is a (1x96) array
format_plural1 = '%d bottles of beer on the wall,\n%d bottles of beer,\n';
format_plural2 = 'Take one down, pass it around,\n%d bottles of beer on
the wall.\n\n';
format_sing1 = '%d bottle of beer on the wall,\n%d bottle of beer,\n';
format_sing2 = 'Take one down, pass it around,\n%d bottle of beer on the
wall.\n\n';
format_none2 = 'Take it down, pass it around,\nNo bottles of beer on the
wall.\n';
% bottles 99, 2 & 1 are treated as special cases
fprintf([format_plural1 format_plural2], 99,99,num_array,2)
fprintf([format_plural1 format_sing2], 2,2,1)
fprintf([format_sing1 format_none2], 1,1)
Microsoft Word
The scripting language used for Microsoft Word
Sub MAIN
REM "99 bottles of beer on the wall"
REM Microsoft Word WordBasic macro language version
REM written by Mark Pilgrim, f8dy@netaxs.com
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
Mathematica
Mathematica is a computer algebra system.
(* Mathematica version of 99 Bottles of Beer *)
(* Bill Dall *)
Do[If[i1,
Print[i, " more bottles of beer on the wall. ",i,
" more bottles of beer."];
Print["Take one down, pass it around."],
(* else *)
Print["1 more bottle of beer on the wall. 1 more bottle of beer."];
Print["Take one down, pass it around."];
Print["No more bottles of beer on the wall."]
], (* If *)
{i,99,1,-1}]
Logo
Logo is a simple language, suitable for teaching and famed for its "turtle" graphics. More
info
; by Augusto Chioccariello
to 99bottles
for [i 99 1 -1] [
print se :i [bottle(s) of beer on the wall]
print se :i [bottle(s) of beer]
print [take one down, pass it around]
print se (:i - 1) [bottle(s) of beer on the wall]]
end
Mops
Mops is a Forth-based OOP freeware package for developing Macintosh applications.
\ Mops Beer (object paradigm)
\ by Bruce Bennett
:class BEER super{ object }
record{
var
n
}
private
:m lastBottle:
cr ." 1 last bottle of beer on the wall," cr
." Only 1 bottle of beer." cr
." Take it down, pass it around --" cr
." No more bottles of beer!" cr
;m
public
:m bottlesOf: { n -- }
1 n DO
i 1 = IF lastBottle: self LEAVE THEN cr
i . ." bottles of beer on the wall," cr
i . ." bottles of beer." cr
." Take one down, pass it around," cr
i 2 = IF i 1 - . ." last bottle of beer." ELSE
i 1 - . ." bottles of beer on the wall." THEN cr
-1 +LOOP
;m
;class
beer
beer!
99 bottlesOf: beer!
M5
!rem 99 bottles of beer in the M5 macro language
!rem programmer Ron Franke-Polz - ronaldFP@aol.com
!rem
!rem define a macro which contains the song
!rem
!macro song
[v $1] [if [eq $1 1] "bottle" "bottles"] of beer on the wall,
[v $1] [if [eq $1 1] "bottle" "bottles"] of beer,
take one down and pass it around,
[if [eq [- $1 1] 1] "No more" [- $1 1]] [if [eq [- $1 1] 1] "bottle"
"bottles"] of beer on the wall.
!endm
!rem
!rem sing the song 99 times
!rem
!eval [set count 99]
!while count
!song (count)
!eval [-- count]
!endwhile
IRC II
This is the scripting language for Inter Relay Chat.
alias bottles.start {
while (1) {
@ bottles.count = 99;
while ( bottles.count )
{
bottles.sayonwall ,
bottles.say
echo Take one down and pass it around
@ bottles.count = bottles.count - 1
bottles.sayonwall .
echo
}
echo No more bottles of beer on the wall,
echo no more bottles of beer,
echo Go to the store and buy some more,
echo 99 bottles of beer on the wall.
echo
}
}
alias bottles.sayonwall echo $bottles.count bottles of beer on the wall$0
alias bottles.say echo $bottles.count bottles of beer,
bottles.start
LIFE
LIFE is a constraint logic programming language.
%% LIFE version of 99 Bottles of beer
%% by Denys Duchier duchier@cs.sfu.ca
how_many(0) - "no more".
how_many(N) - N.
action(0) - 99 | write("Go to the store and buy some more.\n").
action(N) - N-1 | write("Take one down, pass it around.\n").
bottles(1) - "bottle".
bottles(N) - "bottles".
sing(N) :write(H:how_many(N)," ",B:bottles(N)," of beer on the wall, ",
H," ",B," of beer.\n"),
write(how_many(M:action(N))," ",bottles(M),
" of beer on the wall.\n\n"),
sing(M).
Make
make is technically a tool for building applications, but it's amazing what a pre-processor
and recursion can do for you.
#
#
# quick effort at 99 bottles program using gnu make
#
# the file must be called makefile.bottles
#
# Author: Andrew Dunstan (andrew.dunstan@its.maynick.com.au)
#
default:
$(MAKE) -f makefile.bottles BOTTLES=99 bottles
.SILENT:
bottles:
echo $(BOTTLES) bottles of beer on the wall
echo $(BOTTLES) of beer
echo Take one down and pass it around
ifeq ($(BOTTLES),0)
echo No bottles of beer on the wall
else
echo `expr $(BOTTLES) - 1` bottles of beer on the wall
echo
$(MAKE) -f makefile.bottles BOTTLES=`expr $(BOTTLES) - 1`
endif
bottles
Maple V3
#
# Vanilla (non-graphical) version of 99 Bottles as sung
# reluctantly by Maple V3, and only under the agreement that it
# will be called on to perform the song properly, in color, and with
# appropriate animation... someday
#
# Authors: Hill and Burstall (handb@ionet.net)
#
lyrics:=(` Bottle`,` of beer on the wall! ` ,` of beer! Take`,
` down, pass it around...`):
for i from 99 by -1 to 3 do
print(cat ( i ,lyrics[1],`s`,lyrics[2]),
cat(i, lyrics[1],`s`,lyrics[3],` one`,lyrics[4]),
cat(i-1,lyrics[1],`s`,lyrics[2]))
od;
print(cat ( i ,lyrics[1],`s`,lyrics[2]), cat(i, lyrics[1],`s`,lyrics[3],`
one`,
lyrics[4]), cat(i-1,lyrics[1],lyrics[2]));
print(cat ( `1` ,lyrics[1],lyrics[2]), cat(`1`, lyrics[1],lyrics[3],` it`,
lyrics[4]), cat(`0`,lyrics[1],`s`,lyrics[2]));
ML
(* ML version of 99 bottles of beer
*)
(*
- Using pattern of functions parameters
*)
(*
and Recursion(like other functional programming langauges) *)
(* Written by Jong-Won Choi(jwchoi@gsen.goldstar.co.kr)
*)
(*
Nov 13, 95 *)
fun NinetyNineBottlesOfBeer(0) =
print("\n No more bottles of beer on the wall\n")
| NinetyNineBottlesOfBeer(1) =
(print("\n 1 bottle of beer on the wall, 1 bottle of beer.");
print("\n Take one down and pass it around.");
NinetyNineBottlesOfBeer(0))
| NinetyNineBottlesOfBeer(NumberOfBottles:int) =
(print("\n "); print(NumberOfBottles);
print(" bottle of beer on the wall, ");
print(NumberOfBottles);
print(" bottle of beer.");
print("\n Take one down and pass it around.");
NinetyNineBottlesOfBeer(NumberOfBottles - 1));
Mercury
A purely declarative logic programming language. Click for more information.
% file: beer.m
% author: Fergus Henderson <fjh@cs.mu.oz.au>
% date: Thursday 9th November 1995
:- module beer.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module int.
main -- beer(99).
:- pred beer(int::in, io__state::di, io__state::uo) is det.
beer(N) -( { N = 0 } io__write_string("Go to the store and buy some more!")
;
bottles(N),
io__write_string(" on the wall,\n"),
bottles(N),
io__write_string(".\n"),
io__write_string("Take one down, pass it around,\n"),
{ N1 is N - 1 },
bottles(N1),
io__write_string(" on the wall.\n\n"),
beer(N1)
).
:- pred bottles(int::in, io__state::di, io__state::uo) is det.
bottles(N) -( { N = 0 } io__write_string("No more bottles of beer")
; { N = 1 } io__write_string("1 bottle of beer")
;
io__write_int(N),
io__write_string(" bottles of beer")
).
Lingo
Lingo is Macromedia's Director scripting language.
-- Lingo version of 99 Bottles of Beer
-- programmer: John R. Nyquist SynapseDes@aol.com
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
Inform
Inform is a compiler meant for writing adventure games for the so-called "Z-machine"
created by Infocom. Click here for more information.
! --------------------------------------------------------------------------
! 99 Bottles of Beer on the Wall, Inform version [smaller]
!
_
! Torbjorn Andersson, (d91tan@Minsk.DoCS.UU.SE) December 1995
! -------------------------------------------------------------------------! For technical reasons, the first function is not allowed to use local
! variables.
Global i = 99;
[ Main;
print "^^^^";
while (i > 0) {
new_line;
print i, (char) ' ', (PluralBottle) i, " of beer on the wall,^";
print (Chorus) i--;
print "You take one down & pass it around^";
print (Chorus) i;
}
@read_char 1 i;
quit;
];
[ PluralBottle n;
if (n == 1)
print "bottle";
else
print "bottles";
];
[ Chorus n;
print "
";
if (n == 0)
print "No more";
else
print n;
print_ret (char) ' ', (PluralBottle) n, " of beer";
];
end;
Inform 6
Inform 6 is version 6 of a compiler meant for writing adventure games for the so-called "Zmachine" created by Infocom. It seems to be more object oriented than the original sent to
me. Click here for more information.
! ---------------------------------------------------------------------------! 99 Bottles of Beer on the Wall, Inform 6 version.
!
! Torbjörn Andersson, (d91tan@Student.DoCS.UU.SE), August 1997
! ---------------------------------------------------------------------------Constant NUM_BOTTLES 99;
Object wall
private
bottles_left,
with
init [ n;
self.bottles_left = n;
],
bottle_name [;
if (self.bottles_left == 1)
return "bottle";
return "bottles";
],
bottle_count [;
return self.bottles_left;
],
take_one_down [;
self.bottles_left--;
];
[ Main;
wall.init(NUM_BOTTLES);
while (wall.bottle_count() 0) {
print
"^",
wall.bottle_count(), " ", (string) wall.bottle_name(),
" of beer on the wall,^ ",
wall.bottle_count(), " ", (string) wall.bottle_name(),
" of beer^You take one down and pass it around^ ";
wall.take_one_down();
if (wall.bottle_count() == 0)
print "No more";
else
print wall.bottle_count();
print " ", (string) wall.bottle_name(), " of beer on the wall.^";
}
];
KidSim
This is cool, but I couldn't really include the code for it here. Click here for more
information, including an animation of 99BoB's.
IDL
; The Bottles of Beer song (c) 1996 Eric Korpela
(korpela@ssl.berkeley.edu)
; USAGE: BOTTLES or BOTTLES, NUMBER
;
pro bottles, number
;
if not(keyword_set(number)) then begin
number=99
print,'BOTTLES: Defaulting to 99 bottles!'
endif
;
; Set up our song structure............
st1=replicate({n0:0,s1:' bottles of beer on the wall.',
$
n1:0,s2:' bottles of beer.',
$
s3:'You take one down and pass it around.',
$
n2:0,s4:' bottles of beer on the wall.'}, number)
;
; put in the appropriate numbers
i=(number-1)-indgen(number)
st1(*).n0=i+1
st1(*).n1=i+1
st1(*).n2=i
;
print,st1,format='(i3,a/i3,a/a/i3,a//)'
;
end
MAGIC/L
A procedural language written in Forth. Originally ran on Z80's under CP/M and later
available for IBM-PCs and Sun 3s.
; MAGIC/L version of the beer bottle song
; (c) 1996 Eric Korpela (korpela@ssl.berkeley.edu)
; WARNING! All the spaces are necessary!
;
; Add the help entry....
.subject bottles
Usage: bottles ( number )
.
; and here's the procedure
define bottles
integer number
local integer current
;
current := number
while ( current > 1 )
print current , " bottles of beer on the wall."
print current , " bottles of beer."
print "You take one down and pass it around."
current := current - 1
print current , " bottles of beer on the wall."
print
repeat
;
print 1 , " bottle of beer on the wall."
print 1 , " bottle of beer."
print "You take one down and pass it around."
print "No bottles of beer on the wall.
end
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>
MUSH/TinyTIM/TinyMUSH
Heaven help us! Stuff to program multi-user games on the net.
A bunch of drunk engineers(#54326)
Owner: eric.korpela Key: eric.korpela(#54351PeoZ) Money: 2
You see a bunch of engineers from a south bay firm who look like they've
had a
bit too much to drink. They are random walking all over town, stopping
where
ever they can find approprate beverages. I bet they'd sing "99 bottles of
beer" if you asked them to.
Listen: *sing*99*
Ahear: use me;
@wait 3={
@while gt(V(vi),1)={
@if eq(V(vj),V(vi))=think,{@trigger me/vy;@decrement me/vj}
};
@wait DONE=:collapses into an algoholic stupor.
}
VY: say concat(V(vi),bottles of beer on the wall!);
say concat(V(vi),bottles of beer.);
say You take one down, and pass it around;
@decrement me/vi;
say concat(V(vi),bottles of beer on the wall.);
@emit
Ause: @vi me=99;@vj me=100
Ouse: takes a deep breath and begins to sing.
Scent: They smell of 43 different types of liquor.
Functions: #69
KUIP
*******************************************
* KUIP version of 99 bottles of beer
*
* r.p.hofmann f15rph@ips105.desy.de
*
* http://ips105.desy.de:8765/
*
*******************************************
* about KUIP:
*
* R.Brun, P.Zanarini
*
* KUIP - Kit for a User Interface Package *
* Program library I202. CERN 1988
*
*******************************************
macro beer nbott=99 ndown=1
if [ndown] > 0 goto ndok
ndown=-[ndown]
ndok:
if [ndown] > 1 goto mored
alias/create pron it
goto oned
mored:
alias/create pron them
oned:
if [nbott] < 1 goto end
if [nbott] = 1 goto one
alias/create bob 'bottles of beer'
alias/create otw 'on the wall'
pass:
mess [nbott] bob otw
mess [nbott] bob
mess take [ndown] down and pass pron all around
nbott=[nbott]-[ndown]
if [nbott] <> 1 goto moreb
mess 1 bottle of beer otw
goto oneb
moreb:
mess [nbott] bob otw
oneb:
if [ndown] = 0 goto end
if [nbott] > 1 goto pass
if [nbott] < 1 goto end
one:
mess 1 bottle of beer otw
mess 1 bottle of beer
mess take [ndown] down and pass pron all around
nbott=1-[ndown]
mess [nbott] bottles of beer otw
if [nbott] < 1 goto end
end:
MOO
@args #230:"@99" none none none
@chmod #230:@99 rxd
@program #230:@99
"Programmed by Malcolm Gin-Hopwood y Silva (perigee@dgsys.com)";
"Runs on LambdaMOO core 1.7.9 and 1.8.0";
"This one spares any standers by the terror of 99 bottles of beer on the
wall,
and does numbers to english passing as well. Woo woo.";
count = 99;
while (count > 0)
$command_utils:suspend_if_needed(0);
this:_round_of_beer(count);
count = count - 1;
endwhile
player:tell("Time to buy more beer.");
.
@args #230:"_round_of_beer" this none this
@program #230:_round_of_beer
beer = args[1];
player:tell(($string_utils:capitalize($string_utils:english_number(beer))
+
((beer == 1) ? " bottle " | " bottles ")) + "of beer on the wall.");
player:tell(($string_utils:capitalize($string_utils:english_number(beer))
+
((beer == 1) ? " bottle " | " bottles ")) + "of beer...");
player:tell("Take one down and pass it around.");
player:tell(($string_utils:capitalize($string_utils:english_number(beer 1))
+ (((beer - 1) == 1) ? " bottle " | " bottles ")) + "of beer on the
wall.");
player:tell();
.
Mark IV
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
RCDUMMYFD S U
S
T
R
RFSUBFILE SM4SUBF1
ERDATE
AA
AA
Michael Passer
AA
AA
This program requires one dummy record of input
AA
(the M4OLD DD) to trigger execution. Output is
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
SING
SING
SING
SING
SING
SING
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
AA
sent to the first subfile (M4SUBF1 DD).
AA
TFBOTTLESZ 3Z
100
AA
----+----1----+TFBOB
15C
BOTTLES OF BEER
TFOTW
11C
ON THE WALL
TFTOD
13C
TAKE ONE DOWN
TFPIA
14C
PASS IT AROUND
TFCOMMA
1C
,
TFPERIOD
1C
.
TFBLANK
1C
PR
GO SUB SING
ERDATE
PR
TBOTTLESZEQD0
PR
GS RETURN
PR
GO SUB CHORUS
PR
R TMINUS1Z
PR
GO REQUEST SING
ERDATE
TFMINUS1Z
3Z
TFBOTTLES
3C
TFMINUS1
2C
PR
TBOTTLESZ- D1
PR
R TBOTTLESZ
PR
R TMINUS1Z
E1
NR SUBFILE
R1
TBOTTLES
R1
TBLANK
R1
TBOB
R1
TBLANK
R1
TOTW
R1
TCOMMA
E2
NR SUBFILE
R2
TBOTTLES
R2
TBLANK
R2
TBOB
R2
TCOMMA
E3
NR SUBFILE
R3
TTOD
R3
TCOMMA
R3
TBLANK
R3
TPIA
R3
TCOMMA
E4
NR SUBFILE
R4
TMINUS1
R4
TBLANK
R4
TBOB
R4
TBLANK
R4
TOTW
R4
TPERIOD
E5
NR SUBFILE
R5
TBLANK
S
100
TBOTTLESZ
S
TMINUS1Z
TBOTTLES
TMINUS1
V
V
V
V
V
ISM/SML
SML is the language used in ISM/Openmaster, the BULL Administrative Platform. ISM/SML
(for Integrated System Management / System Management Language).
; Code Begin
; A.Brunet@frcl.bull.fr (Alain Brunet)
(defun beer(cap)
(dotimes (i cap)
(print (- cap i) " bottle" (if (= i (- cap 1)) "" "s") " of beer on
the wall.")
(print "Take one down, pass it around.\n")
)
(print "Time to buy more beer !")
)
(beer 99)
Korn Shell
Yet another UN*X shell.
#!/bin/ksh
# Korn shell version of 99 Bottles
# Dave Plonka - plonka@carroll1.cc.edu
typeset -i n=99
typeset bottles=bottles
typeset no
while (( n ))
do
print "${n?} ${bottles?} of beer on the wall,"
print "${n?} ${bottles?} of beer,\ntake one down, pass it around,"
n=n-1
case ${n?} in
0)
no=no
bottles=${bottles%s}s
;;
1)
bottles=${bottles%s}
;;
esac
print "${no:-${n}} ${bottles?} of beer on the wall.\n"
done
exit
LabVIEW
An icon based language. Click for more information
Leda
Leda is a multiparadigm programming language designed by Timothy A. Budd. It supports
imperative, object-oriented, functional and logic programming paradigms. Click here for
Information and an interpreter.
{ 99 bottles of beer, Leda version
{ By Arion Lei (philipl@cs.ust.hk)
}
}
include "std.led";
const
verse1 := " bottles of beer on the wall,\n";
verse2 := " bottles of beer. Take one down, pass it around,\n";
verse3 := " bottles of beer on the wall.\n";
verse4 := "No more bottles of beer on the wall, no more bottles of
beer.\n";
verse5 := "Go to the store and buy some more... 99 bottles of
beer.\n\n";
{ ========== IMPERATIVE PROGRAMMING =========== }
function proc_Beer (bottleTotal : integer);
var bottleLeft : integer;
begin
bottleLeft := bottleTotal;
while bottleLeft0 do begin
print(bottleLeft); print(verse1);
print(bottleLeft); print(verse2);
bottleLeft := bottleLeft - 1;
if (bottleLeft0) then begin
print(bottleLeft); print(verse3);
end;
end;
print(verse4);
print(verse5);
end; { proc_Beer }
{ ========== OBJECT-ORIENTED PROGRAMMING =========== }
class Beers;
var
bottleLeft : integer;
function more () - boolean;
begin
return bottleLeft > 0;
end;
function consume1 ();
begin
print(bottleLeft); print(verse1);
print(bottleLeft); print(verse2);
bottleLeft := bottleLeft - 1;
if (bottleLeft0) then begin
print(bottleLeft); print(verse3);
end else begin
print(verse4);
print(verse5);
end;
end;
end; { class Beers }
function obj_Beer (bottleTotal : integer);
var obeer : Beers;
begin
obeer := Beers(bottleTotal);
while (obeer.more()) do obeer.consume1();
end; { obj_Beer }
{ ========== FUNCTIONAL PROGRAMMING =========== }
function func_Beer (num : integer) - function();
begin
return function ();
begin
print(num); print(verse1);
print(num); print(verse2);
if num1 then begin
print(num-1); print(verse3);
func_Beer(num-1)();
end else begin
print(verse4);
print(verse5);
end;
end;
end; { func_Beer }
{ ========== LOGIC PROGRAMMING =========== }
function log_Beer (bottleTotal : integer);
function pickBottle (byRef left : integer, total : integer)-relation;
begin
if total = 0 then
return false
else
return left relation;
begin
print(i); print(verse1);
print(i); print(verse2);
if i1 then begin
print(i-1); print(verse3);
end else begin
print(verse4);
print(verse5);
end;
return true;
end;
var i : integer;
begin
for pickBottle(i, bottleTotal) & consume(i) do begin end;
end; { log_Beer }
{ ---------- MAIN PROGRAM ---------- }
var bottleTotal : integer;
begin
bottleTotal := 99;
proc_Beer (bottleTotal);
obj_Beer (bottleTotal);
func_Beer(bottleTotal)();
log_Beer(bottleTotal);
end;
Limbo
Limbo is compiler for Lucent Technologies new Inferno Operating System.
implement BeerBottles;
include "sys.m";
sys: Sys;
include "draw.m";
draw: Draw;
BeerBottles: module
{
init: fn(ctxt: ref Draw-Context, agv: list of string);
};
init(ctxt: ref Draw-Context, argv: list of string)
{
sys = load Sys Sys-PATH;
for (int bottles = 99; bottles > 0; bottles--) {
sys-print("%d bottle(s) of beer on the wall,\n",bottles);
sys-print("%d bottle(s) of beer.\n",bottles);
sys-print("Take one down, pass it around,\n");
sys-print("%d bottle(s) of beer on the wall.\n\n");
}
}
M-Speak
M-Speak is a word-processing macro language created in the late 1970's for the Spellbinder
word processor.
;-)
Spellbinder Macro to print "99 Bottles of Beer on the Wall"
(-;
; by Andy Goldberg
;
:%A="s"
;set variable for plural
:%1=99
;initialize counter
:%2=%1-1
;decrement at top of loop
s//%1 bottle%A of beer on the wall</
;lyric
s//%1 bottle%A of beer</<
s//Take one down and pass it around</
:on %2-1 /+4 / /+1
:%A=""
plural
s//%2 bottle%A of beer on the wall.<</
:%1=%1-1
:on -1 /-9
s//No more bottles of beer on the wall.</
/t/p/wo/song.txt/t/gd
(optional)
;check for last stanza
;if last stanza clear
;last line and blank line
;check for end
;if not end then loop
;ending line
;print, save and end
MetaPost
For more information on MetaPost see http://cm.bell-labs.com/who/hobby/MetaPost.html
% MetaFont/MetaPost version of ``99 bottles'' by Tomasz J. Cholewo
% For more information see http://cm.bell-labs.com/who/hobby/MetaPost.html
for i:=99 downto 1:
message decimal i & " bottle" if i1: & "s" fi & " of beer on the wall,";
message decimal i & " bottle" if i1: & "s" fi & " of beer.";
message "Take one down, pass it around.";
endfor;
message "No more bottles of beer on the wall.";
end
ILE AS/400
This is IBM's next generation of RPG.
H*
H* ILE RPG/400 - 99 Bottles of Beer on the Wall.
H* (IBM AS/400 Midrange Platform)
H* (Program Source BOTTLESR1)
H*
FBottlesS1 O
E
WorkStn
C
C
Z-Add
*HIVAL
Bottles1
C
C
DoW
Bottles1 *Zero
C
Eval
Bottles2 = Bottles1
C
Write
#Display
C
Sub
1
Bottles1
C
EndDo
C
C
Eval
*InLR = *On
C
----------------------A*
A*
A*
A*
A*
A
A
A
A
A
A
A
A
A
ILE RPG/400 - 99 Bottles of Beer on the Wall.
(IBM AS/400 Midrange Platform)
(Display File Source BOTTLESS1)
DSPSIZ(24 80 *DS3)
FRCDTA
R #DISPLAY
BOTTLES1
2Y 0O
BOTTLES2
2Y 0O
4 2EDTCDE(4)
4 5'Bottles of Beer On the Wall,'
4 34EDTCDE(4)
4 37'Bottles of Beer,'
5 2'Take one down, pass it around.'
MPTMON
; MPTMON (Multi Processor Test Monitor) is a debugging
; tool for telephonic exchanges from Alcatel.
; These two macros do the beer job..
REM MAC Bottle
DEF MAC Bottle
WR %0,' Bottle',&
IF %0<>1\'s',&
END
' of Beer',&
IF %1\' on the Wall',&
END
'%2'
EM
REM MAC Beer
DEF MAC Beer ; jr_31jan97
ADD SYM.I=99T
BAS=T
COU 99T
Bottle:.I,TRUE,','
Bottle:.I,FALSE,'.'
'
Take one down, pass it around,'
.I=.I-1
Bottle:.I,TRUE,'.'
''
END
EM
Beer:
Model 204
*Model 204 (or M204 as it's commonly called) is a proprietary
*database and language of Computer Corporation of America.
*It was first developed over 30 years ago by the NSA.
*Some claim that it's the fastest IBM Mainframe database.
*It is good for databases with large record counts.
*The Department of Social Security of Australian employs
*hundreds of M204 programmers.
*Add-on packages permit SQL and Web access.
*
* Written by Kevin Giles, NCI Information Systems Inc.
* e-mail: KGILES@USGS.GOV
*
* 100 bottles of beer / take one / action
*
*LOWER
BEGIN
DECLARE %S IS STRING LEN 1 COMMON
FOR %BOTTLE FROM 100 TO 0 BY -1
CALL CHECKPLURAL(%BOTTLE)
PRINT %BOTTLE AND 'bottle' WITH %S AND 'of beer on the wall.'
PRINT %BOTTLE AND 'bottle' WITH %S AND 'of beer.'
PRINT 'Take one down, pass it around.'
CALL CHECKPLURAL(%BOTTLE-1)
IF %BOTTLE-1 = +0 THEN PRINT 'No bottles of beer on the wall.'
SKIP 1 LINE
PRINT 'No bottles of beer on the wall.'
PRINT 'No bottles of beer.'
PRINT 'Go to the store, buy some more.'
%BOTTLE = 101
CALL CHECKPLURAL(%BOTTLE-1)
END IF
PRINT $UNBLANK(%BOTTLE-1) AND 'bottle' WITH %S AND 'of beer on the wall.'
SKIP 1 LINE
END FOR
SUBROUTINE CHECKPLURAL (%PASSVAL STRING DP 0 INPUT)
IF %PASSVAL NE +1 THEN %S = 's'
ELSE
%S = ''
END IF
END SUBROUTINE
END
Miranda
|| 99 bottles of beer in Miranda - the hideous functional programming
lingo
|| by Tim Walls, tjw1@doc.ic.ac.uk, http://www-
students.doc.ic.ac.uk/~tjw1/
||
|| Call with 'bottlesofbeer 99'.
bottlesofbeer :: num -> [char]
bottlesofbeer n = "\nNo more bottles of beer on the wall, \n"
++ "no more bottles of beer.\n" , if n = 0
= "\nOne more bottle of beer on the wall, one bottle of
beer,\n"
++ "Take one down and pass it around"
++ (bottlesofbeer (n-1))
, if n = 1
= "\n" ++ shownum(n) ++ " bottles of beer on the wall,"
++ shownum(n)
++ " bottles of beer,\nTake one down and pass it
around"
++ (bottlesofbeer (n-1))
, otherwise
K
s:" bottles of beer on the wall, bottles of beer.
If bottles should happen to fall,
bottles of beer on the wall.
"
d:{`0:,/|(r[];u[]),n'|3_!x+1}
r:{k[(1;1;"that";"No more")]_di 8 39 64}
u:{n[2]_di 105}
n:{k(x;x;"one of those";x-1)}
k:{,/($x),'0 30 51 83_ s}
Lakota
Lakota is a shell language used mainly in the TRUEchange configuration management
package from True Software. Code courtesy Beirne "Bern" Konarski.
#! /usr/local/lsh
set-string s s
set-string item one
do i 99 1 -1
print (i) bottle(s) of beer on the wall,
print (i) bottle(s) of beer.
print You take (item) down, pass it around,
set-string j {- (i) 1}
if {=? (j) 1}
set-string s
set-string item it
if {=? (i) 1}
print No more bottles of beer on the wall.(newline)
else
print (j) bottle(s) of beer on the wall.(newline)
cycle
Luck
Luck is custom programming language. 99BoB code contributed by the creator.
luck: Beer99
proc: main
new #bottles = 99
loop: #bottles 0
saysolo #bottles
say " bottle(s) of beer on the wall."
saysolo
#bottles
say " bottle(s) of beer."
say "Take one down and pass it
around."
#bottles = #bottles - 1
if: #bottles = 0
saysolo "No
more"
end
if: #bottles 0
saysolo #bottles
end
say "
bottle(s) of beer on the wall."
say
end
end
Magma
Magma is a computer algebra system from Australia.
verse := function(n)
bottles := function(n)
return n eq 1 select "1 bottle"
else IntegerToString(n) cat " bottles";
end function;
return current cat " of beer on the wall,\n" cat
current cat " of beer;\n" cat
"Take one down, pass it around,\n" cat
bottles(n - 1) cat " of beer on the wall.\n\n"
where current is bottles(n);
end function;
song := procedure()
print &cat [verse(n) : n in [99 .. 1 by -1]] cat
"Go to the store and get some more.";
end procedure;
Jam
Jam is a make-like system for building programs, etc.
# Jamfile for 99 Bottles of beer on the wall.
# David Brandon (brandon@aspentech.com)
ALWAYS beer ;
rule Drink {
for tenbeers in 9 8 7 6 5 4 3 2 1 "" {
for beers in 9 8 7 6 5 4 3 2 1 0 {
b = $(tenbeers)$(beers) ;
if ( $(b) != 99 ) {
ECHO "$(b) bottles of $(
Macintosh WordPerfect
; Here is the Macintosh WordPerfect macro language version.
Assign (Var01;99)
Repeat
Type Var (Var01)
Type ( bottles of beer on the wall. )
Type Var (Var01)
Type ( bottles of beer. )
Type (Take one down, pass it around. )
Assign (Var01;Var01-1)
Type Var (Var01)
Type ( bottles of beer on the wall.)
Hard Return
Until (Var01=0)
Modula 2
(* Modula-2 version of 99 Bottles of Beer
*)
(* Tested on a VAX 7700 running OpenVMS
*)
(* Programmer: Jeremy Rule rulej@tempest.adsnet.net *)
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.
Modula 3
MODULE BottlesOfBeer EXPORTS Main;
FROM IO IMPORT Put ;
FROM Fmt IMPORT Int ;
VAR bottles := 99 ;
BEGIN
WHILE (bottles > 0) DO
Put(Int(bottles) & " bottle(s) of beer on the wall,\n") ;
Put(Int(bottles) & " bottle(s) of beer. \n") ;
Put("Take one down, and pass it around,\n");
DEC(bottles);
Put(Int(bottles) & " bottle(s) of beer on the wall.\n");
END ;
END BottlesOfBeer.
LPC
LPC was originally conceived as a object oriented C-like language for writing MUDs and
being able to modify them on the fly.
// beersong.c
// an implementation in the LPC language
// Tim Hollebeek, 6/6/95 - tim@debusy.Princeton.EDU
private string bottles(int n) {
switch (n) {
case 0: return "no more bottles of beer";
case 1: return "1 bottle of beer";
default: return n + " bottles of beer";
}
}
void beersong() {
for (int i = 99; i; i--) {
write(bottles(i) + " on the wall, " + bottles(i)
+ ", take one down, pass it around, "
+ bottles(i - 1) + " on the wall.\n");
}
}
Mumps
; The following is a single line of code
beer
; Randy M. Hayman (haymanr@icefog.alaska.edu)
for i=99:-1:1 w !,i," bottle",$S(i=1:"",1:"s")," of beer on the wa
ll, ",i," bottle",$S(i=1:"",1:"s")," of beer.",!,"Take one down, pass it a
round, ",i-1," bottle",$S(i=2:"",1:"s")," of beer on the wall.",!
ITCL
#!/usr/local/bin/itcl_sh
# [incr Tcl] version of "99 bottles of beer"
# Author: Steven Grady
# grady@xcf.berkeley.edu
itcl_class bottle {
constructor {config} {
incr numBottles
}
destructor {
incr numBottles -1
}
method drink {} {
puts "Take one down, pass it around,"
$this delete
}
proc numBottleStr {} {
switch $numBottles {
0 {
return "No more bottles of beer"
}
1 {
return "1 bottle of beer"
}
default {
return "$numBottles bottles of beer"
}
}
}
proc numBottles {} {
return $numBottles
}
common numBottles 0
}
proc createBottles {numBottles} {
for {set i 0} {$i < $numBottles} {incr i} {
bottle #auto
}
}
createBottles 99
foreach b [itcl_info objects -class bottle] {
set str [bottle :: numBottleStr]
puts "$str on the wall, $str"
$b drink
puts "[bottle :: numBottleStr] on the wall."
}
M4
A Unix macro language.
# by Ozan S. Yigit" (oz@sni.ca)
#
define(BOTTLES,`ifelse($1, 0, no more bottles,
$1, 1, one bottle, $1 bottles) of beer') dnl
define(BEER,`ifelse(eval($1 > 0), 1,
`BOTTLES($1) on the wall, BOTTLES($1)
take one down, pass it around
BOTTLES(eval($1 - 1)) on the wall.
BEER(eval($1 - 1))')') dnl
BEER(10)
Java
Java is a machine independent compiler based on C++ which targets to pseudo-code.
// java version of 99 bottles of beer on the wall
// 1995 Sean Russell (ser@cs.uoregon.edu)
class bottles
{
public static void main(String args[])
{
String s = "s";
for (int beers=99; beers-1;)
{
System.out.print(beers + " bottle" + s + " of beer on the wall, ");
System.out.println(beers + " bottle" + s + " of beer, ");
if (beers==0)
{
System.out.print("Go to the store, buy some more, ");
System.out.println("99 bottles of beer on the wall.\n");
System.exit(0);
}
else
System.out.print("Take one down, pass it around, ");
s = (--beers == 1)?"":"s";
System.out.println(beers + " bottle" + s + " of beer on the
wall.\n");
}
}
}
Java Script
Interpretive Java.
/**
* 99 Bottles of Beer on the Wall in JavaScript
* This program prints out the lyrics of an old pub song.
* Copyright (C) 1996, Brian Patrick Lee (blee@media-lab.mit.edu)
*/
if (confirm("Are you old enough to read about beer\n" +
"according to your local community standards?")) {
for (i = 99 ; i > 0 ; i--) {
j = i - 1;
if (i != 1) {
icase = "bottles";
} else {
icase = "bottle";
}
if (j != 1) {
jcase = "bottles";
} else {
jcase = "bottle";
}
document.writeln(i + " " + icase + " of beer on the wall,");
document.writeln(i + " " + icase + " of beer,");
document.writeln("Take 1 down, pass it around,");
if (j != 0) {
document.writeln(j + " " + jcase + " of beer on the wall.");
} else {
document.writeln("No more bottles of beer on the wall!");
}
document.writeln()
}
} else {
document.write("You might want think about moving to another
community.")
}
INTERCAL
INTERCAL is a real language, apparently created with the notion that programming ought
to be hard. Program courtesy Matt Dimeo.
PLEASE DO ,10
Icon
# Scott E Gilbert <scott@cs.arizona.edu>
procedure main()
t:= table("bottles")
t[1]:= "bottle"
every n:= 100 to 1 by -1 do {
write(n, " ", t[n], " of beer on the wall.\n",
n, " ", t[n], " of beer.\n",
"Take one down, Pass it around.\n",
n-1, " ", t[n-1], " of beer on the wall.\n"
)
}
end
MATLAB
Click for more information.
% MATLAB verion of 99 Bottles of beer
% by Bill Becker
function beer(n);
if nargin<1, n=99; end
for i=n:-1:1,
disp([int2str(i) ' Bottles of beer on the wall,'])
disp([int2str(i) ' Bottles of beer,'])
disp('Take one down and pass it around,')
if i1, disp([int2str(i-1) ' Bottles of beer on the wall.']),end
end
disp('No more bottles of beer on the wall!')
Here is a version contributed that shows the language in its more "native" form. (Cf. C++)
% MATLAB *vectorized* version of "99 bottles of beer"
% Rich Stein (rich@cs.umbc.edu)
bottles = [98:-1:3]; % bottles 98 to 3 (99, 2 & 1 are treated as special
case)
lines = 3; % need the number of bottles at the beginning of 3 lines
num_array = ones(lines,1) * bottles; % bottles is a (1x96) array
format_plural1 = '%d bottles of beer on the wall,\n%d bottles of beer,\n';
format_plural2 = 'Take one down, pass it around,\n%d bottles of beer on
the wall.\n\n';
format_sing1 = '%d bottle of beer on the wall,\n%d bottle of beer,\n';
format_sing2 = 'Take one down, pass it around,\n%d bottle of beer on the
wall.\n\n';
format_none2 = 'Take it down, pass it around,\nNo bottles of beer on the
wall.\n';
% bottles 99, 2 & 1 are treated as special cases
fprintf([format_plural1 format_plural2], 99,99,num_array,2)
fprintf([format_plural1 format_sing2], 2,2,1)
fprintf([format_sing1 format_none2], 1,1)
Microsoft Word
The scripting language used for Microsoft Word
Sub MAIN
REM "99 bottles of beer on the wall"
REM Microsoft Word WordBasic macro language version
REM written by Mark Pilgrim, f8dy@netaxs.com
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
Mathematica
Mathematica is a computer algebra system.
(* Mathematica version of 99 Bottles of Beer *)
(* Bill Dall *)
Do[If[i1,
Print[i, " more bottles of beer on the wall. ",i,
" more bottles of beer."];
Print["Take one down, pass it around."],
(* else *)
Print["1 more bottle of beer on the wall. 1 more bottle of beer."];
Print["Take one down, pass it around."];
Print["No more bottles of beer on the wall."]
], (* If *)
{i,99,1,-1}]
Logo
Logo is a simple language, suitable for teaching and famed for its "turtle" graphics. More
info
; by Augusto Chioccariello
to 99bottles
for [i 99 1 -1] [
print se :i [bottle(s) of beer on the wall]
print se :i [bottle(s) of beer]
print [take one down, pass it around]
print se (:i - 1) [bottle(s) of beer on the wall]]
end
Mops
Mops is a Forth-based OOP freeware package for developing Macintosh applications.
\ Mops Beer (object paradigm)
\ by Bruce Bennett
:class BEER super{ object }
record{
var
n
}
private
:m lastBottle:
cr ." 1 last bottle of beer on the wall," cr
." Only 1 bottle of beer." cr
." Take it down, pass it around --" cr
." No more bottles of beer!" cr
;m
public
:m bottlesOf: { n -- }
1 n DO
i 1 = IF lastBottle: self LEAVE THEN cr
i . ." bottles of beer on the wall," cr
i . ." bottles of beer." cr
." Take one down, pass it around," cr
i 2 = IF i 1 - . ." last bottle of beer." ELSE
i 1 - . ." bottles of beer on the wall." THEN cr
-1 +LOOP
;m
;class
beer
beer!
99 bottlesOf: beer!
M5
!rem 99 bottles of beer in the M5 macro language
!rem programmer Ron Franke-Polz - ronaldFP@aol.com
!rem
!rem define a macro which contains the song
!rem
!macro song
[v $1] [if [eq $1 1] "bottle" "bottles"] of beer on the wall,
[v $1] [if [eq $1 1] "bottle" "bottles"] of beer,
take one down and pass it around,
[if [eq [- $1 1] 1] "No more" [- $1 1]] [if [eq [- $1 1] 1] "bottle"
"bottles"] of beer on the wall.
!endm
!rem
!rem sing the song 99 times
!rem
!eval [set count 99]
!while count
!song (count)
!eval [-- count]
!endwhile
IRC II
This is the scripting language for Inter Relay Chat.
alias bottles.start {
while (1) {
@ bottles.count = 99;
while ( bottles.count )
{
bottles.sayonwall ,
bottles.say
echo Take one down and pass it around
@ bottles.count = bottles.count - 1
bottles.sayonwall .
echo
}
echo No more bottles of beer on the wall,
echo no more bottles of beer,
echo Go to the store and buy some more,
echo 99 bottles of beer on the wall.
echo
}
}
alias bottles.sayonwall echo $bottles.count bottles of beer on the wall$0
alias bottles.say echo $bottles.count bottles of beer,
bottles.start
LIFE
LIFE is a constraint logic programming language.
%% LIFE version of 99 Bottles of beer
%% by Denys Duchier duchier@cs.sfu.ca
how_many(0) - "no more".
how_many(N) - N.
action(0) - 99 | write("Go to the store and buy some more.\n").
action(N) - N-1 | write("Take one down, pass it around.\n").
bottles(1) - "bottle".
bottles(N) - "bottles".
sing(N) :write(H:how_many(N)," ",B:bottles(N)," of beer on the wall, ",
H," ",B," of beer.\n"),
write(how_many(M:action(N))," ",bottles(M),
" of beer on the wall.\n\n"),
sing(M).
Make
make is technically a tool for building applications, but it's amazing what a pre-processor
and recursion can do for you.
#
#
# quick effort at 99 bottles program using gnu make
#
# the file must be called makefile.bottles
#
# Author: Andrew Dunstan (andrew.dunstan@its.maynick.com.au)
#
default:
$(MAKE) -f makefile.bottles BOTTLES=99 bottles
.SILENT:
bottles:
echo $(BOTTLES) bottles of beer on the wall
echo $(BOTTLES) of beer
echo Take one down and pass it around
ifeq ($(BOTTLES),0)
echo No bottles of beer on the wall
else
echo `expr $(BOTTLES) - 1` bottles of beer on the wall
echo
$(MAKE) -f makefile.bottles BOTTLES=`expr $(BOTTLES) - 1`
endif
bottles
Maple V3
#
# Vanilla (non-graphical) version of 99 Bottles as sung
# reluctantly by Maple V3, and only under the agreement that it
# will be called on to perform the song properly, in color, and with
# appropriate animation... someday
#
# Authors: Hill and Burstall (handb@ionet.net)
#
lyrics:=(` Bottle`,` of beer on the wall! ` ,` of beer! Take`,
` down, pass it around...`):
for i from 99 by -1 to 3 do
print(cat ( i ,lyrics[1],`s`,lyrics[2]),
cat(i, lyrics[1],`s`,lyrics[3],` one`,lyrics[4]),
cat(i-1,lyrics[1],`s`,lyrics[2]))
od;
print(cat ( i ,lyrics[1],`s`,lyrics[2]), cat(i, lyrics[1],`s`,lyrics[3],`
one`,
lyrics[4]), cat(i-1,lyrics[1],lyrics[2]));
print(cat ( `1` ,lyrics[1],lyrics[2]), cat(`1`, lyrics[1],lyrics[3],` it`,
lyrics[4]), cat(`0`,lyrics[1],`s`,lyrics[2]));
ML
(* ML version of 99 bottles of beer
*)
(*
- Using pattern of functions parameters
*)
(*
and Recursion(like other functional programming langauges) *)
(* Written by Jong-Won Choi(jwchoi@gsen.goldstar.co.kr)
*)
(*
Nov 13, 95 *)
fun NinetyNineBottlesOfBeer(0) =
print("\n No more bottles of beer on the wall\n")
| NinetyNineBottlesOfBeer(1) =
(print("\n 1 bottle of beer on the wall, 1 bottle of beer.");
print("\n Take one down and pass it around.");
NinetyNineBottlesOfBeer(0))
| NinetyNineBottlesOfBeer(NumberOfBottles:int) =
(print("\n "); print(NumberOfBottles);
print(" bottle of beer on the wall, ");
print(NumberOfBottles);
print(" bottle of beer.");
print("\n Take one down and pass it around.");
NinetyNineBottlesOfBeer(NumberOfBottles - 1));
Mercury
A purely declarative logic programming language. Click for more information.
% file: beer.m
% author: Fergus Henderson <fjh@cs.mu.oz.au>
% date: Thursday 9th November 1995
:- module beer.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module int.
main -- beer(99).
:- pred beer(int::in, io__state::di, io__state::uo) is det.
beer(N) -( { N = 0 } io__write_string("Go to the store and buy some more!")
;
bottles(N),
io__write_string(" on the wall,\n"),
bottles(N),
io__write_string(".\n"),
io__write_string("Take one down, pass it around,\n"),
{ N1 is N - 1 },
bottles(N1),
io__write_string(" on the wall.\n\n"),
beer(N1)
).
:- pred bottles(int::in, io__state::di, io__state::uo) is det.
bottles(N) -( { N = 0 } io__write_string("No more bottles of beer")
; { N = 1 } io__write_string("1 bottle of beer")
;
io__write_int(N),
io__write_string(" bottles of beer")
).
Lingo
Lingo is Macromedia's Director scripting language.
-- Lingo version of 99 Bottles of Beer
-- programmer: John R. Nyquist SynapseDes@aol.com
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
Inform
Inform is a compiler meant for writing adventure games for the so-called "Z-machine"
created by Infocom. Click here for more information.
! --------------------------------------------------------------------------
! 99 Bottles of Beer on the Wall, Inform version [smaller]
!
_
! Torbjorn Andersson, (d91tan@Minsk.DoCS.UU.SE) December 1995
! -------------------------------------------------------------------------! For technical reasons, the first function is not allowed to use local
! variables.
Global i = 99;
[ Main;
print "^^^^";
while (i > 0) {
new_line;
print i, (char) ' ', (PluralBottle) i, " of beer on the wall,^";
print (Chorus) i--;
print "You take one down & pass it around^";
print (Chorus) i;
}
@read_char 1 i;
quit;
];
[ PluralBottle n;
if (n == 1)
print "bottle";
else
print "bottles";
];
[ Chorus n;
print "
";
if (n == 0)
print "No more";
else
print n;
print_ret (char) ' ', (PluralBottle) n, " of beer";
];
end;
Inform 6
Inform 6 is version 6 of a compiler meant for writing adventure games for the so-called "Zmachine" created by Infocom. It seems to be more object oriented than the original sent to
me. Click here for more information.
! ---------------------------------------------------------------------------! 99 Bottles of Beer on the Wall, Inform 6 version.
!
! Torbjörn Andersson, (d91tan@Student.DoCS.UU.SE), August 1997
! ---------------------------------------------------------------------------Constant NUM_BOTTLES 99;
Object wall
private
bottles_left,
with
init [ n;
self.bottles_left = n;
],
bottle_name [;
if (self.bottles_left == 1)
return "bottle";
return "bottles";
],
bottle_count [;
return self.bottles_left;
],
take_one_down [;
self.bottles_left--;
];
[ Main;
wall.init(NUM_BOTTLES);
while (wall.bottle_count() 0) {
print
"^",
wall.bottle_count(), " ", (string) wall.bottle_name(),
" of beer on the wall,^ ",
wall.bottle_count(), " ", (string) wall.bottle_name(),
" of beer^You take one down and pass it around^ ";
wall.take_one_down();
if (wall.bottle_count() == 0)
print "No more";
else
print wall.bottle_count();
print " ", (string) wall.bottle_name(), " of beer on the wall.^";
}
];
KidSim
This is cool, but I couldn't really include the code for it here. Click here for more
information, including an animation of 99BoB's.
IDL
; The Bottles of Beer song (c) 1996 Eric Korpela
(korpela@ssl.berkeley.edu)
; USAGE: BOTTLES or BOTTLES, NUMBER
;
pro bottles, number
;
if not(keyword_set(number)) then begin
number=99
print,'BOTTLES: Defaulting to 99 bottles!'
endif
;
; Set up our song structure............
st1=replicate({n0:0,s1:' bottles of beer on the wall.',
$
n1:0,s2:' bottles of beer.',
$
s3:'You take one down and pass it around.',
$
n2:0,s4:' bottles of beer on the wall.'}, number)
;
; put in the appropriate numbers
i=(number-1)-indgen(number)
st1(*).n0=i+1
st1(*).n1=i+1
st1(*).n2=i
;
print,st1,format='(i3,a/i3,a/a/i3,a//)'
;
end
MAGIC/L
A procedural language written in Forth. Originally ran on Z80's under CP/M and later
available for IBM-PCs and Sun 3s.
; MAGIC/L version of the beer bottle song
; (c) 1996 Eric Korpela (korpela@ssl.berkeley.edu)
; WARNING! All the spaces are necessary!
;
; Add the help entry....
.subject bottles
Usage: bottles ( number )
.
; and here's the procedure
define bottles
integer number
local integer current
;
current := number
while ( current > 1 )
print current , " bottles of beer on the wall."
print current , " bottles of beer."
print "You take one down and pass it around."
current := current - 1
print current , " bottles of beer on the wall."
print
repeat
;
print 1 , " bottle of beer on the wall."
print 1 , " bottle of beer."
print "You take one down and pass it around."
print "No bottles of beer on the wall.
end
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>
MUSH/TinyTIM/TinyMUSH
Heaven help us! Stuff to program multi-user games on the net.
A bunch of drunk engineers(#54326)
Owner: eric.korpela Key: eric.korpela(#54351PeoZ) Money: 2
You see a bunch of engineers from a south bay firm who look like they've
had a
bit too much to drink. They are random walking all over town, stopping
where
ever they can find approprate beverages. I bet they'd sing "99 bottles of
beer" if you asked them to.
Listen: *sing*99*
Ahear: use me;
@wait 3={
@while gt(V(vi),1)={
@if eq(V(vj),V(vi))=think,{@trigger me/vy;@decrement me/vj}
};
@wait DONE=:collapses into an algoholic stupor.
}
VY: say concat(V(vi),bottles of beer on the wall!);
say concat(V(vi),bottles of beer.);
say You take one down, and pass it around;
@decrement me/vi;
say concat(V(vi),bottles of beer on the wall.);
@emit
Ause: @vi me=99;@vj me=100
Ouse: takes a deep breath and begins to sing.
Scent: They smell of 43 different types of liquor.
Functions: #69
KUIP
*******************************************
* KUIP version of 99 bottles of beer
*
* r.p.hofmann f15rph@ips105.desy.de
*
* http://ips105.desy.de:8765/
*
*******************************************
* about KUIP:
*
* R.Brun, P.Zanarini
*
* KUIP - Kit for a User Interface Package *
* Program library I202. CERN 1988
*
*******************************************
macro beer nbott=99 ndown=1
if [ndown] > 0 goto ndok
ndown=-[ndown]
ndok:
if [ndown] > 1 goto mored
alias/create pron it
goto oned
mored:
alias/create pron them
oned:
if [nbott] < 1 goto end
if [nbott] = 1 goto one
alias/create bob 'bottles of beer'
alias/create otw 'on the wall'
pass:
mess [nbott] bob otw
mess [nbott] bob
mess take [ndown] down and pass pron all around
nbott=[nbott]-[ndown]
if [nbott] <> 1 goto moreb
mess 1 bottle of beer otw
goto oneb
moreb:
mess [nbott] bob otw
oneb:
if [ndown] = 0 goto end
if [nbott] > 1 goto pass
if [nbott] < 1 goto end
one:
mess 1 bottle of beer otw
mess 1 bottle of beer
mess take [ndown] down and pass pron all around
nbott=1-[ndown]
mess [nbott] bottles of beer otw
if [nbott] < 1 goto end
end:
MOO
@args #230:"@99" none none none
@chmod #230:@99 rxd
@program #230:@99
"Programmed by Malcolm Gin-Hopwood y Silva (perigee@dgsys.com)";
"Runs on LambdaMOO core 1.7.9 and 1.8.0";
"This one spares any standers by the terror of 99 bottles of beer on the
wall,
and does numbers to english passing as well. Woo woo.";
count = 99;
while (count > 0)
$command_utils:suspend_if_needed(0);
this:_round_of_beer(count);
count = count - 1;
endwhile
player:tell("Time to buy more beer.");
.
@args #230:"_round_of_beer" this none this
@program #230:_round_of_beer
beer = args[1];
player:tell(($string_utils:capitalize($string_utils:english_number(beer))
+
((beer == 1) ? " bottle " | " bottles ")) + "of beer on the wall.");
player:tell(($string_utils:capitalize($string_utils:english_number(beer))
+
((beer == 1) ? " bottle " | " bottles ")) + "of beer...");
player:tell("Take one down and pass it around.");
player:tell(($string_utils:capitalize($string_utils:english_number(beer 1))
+ (((beer - 1) == 1) ? " bottle " | " bottles ")) + "of beer on the
wall.");
player:tell();
.
Mark IV
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
RCDUMMYFD S U
S
T
R
RFSUBFILE SM4SUBF1
ERDATE
AA
AA
Michael Passer
AA
AA
This program requires one dummy record of input
AA
(the M4OLD DD) to trigger execution. Output is
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
BEER
SING
SING
SING
SING
SING
SING
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
CHORUS
AA
sent to the first subfile (M4SUBF1 DD).
AA
TFBOTTLESZ 3Z
100
AA
----+----1----+TFBOB
15C
BOTTLES OF BEER
TFOTW
11C
ON THE WALL
TFTOD
13C
TAKE ONE DOWN
TFPIA
14C
PASS IT AROUND
TFCOMMA
1C
,
TFPERIOD
1C
.
TFBLANK
1C
PR
GO SUB SING
ERDATE
PR
TBOTTLESZEQD0
PR
GS RETURN
PR
GO SUB CHORUS
PR
R TMINUS1Z
PR
GO REQUEST SING
ERDATE
TFMINUS1Z
3Z
TFBOTTLES
3C
TFMINUS1
2C
PR
TBOTTLESZ- D1
PR
R TBOTTLESZ
PR
R TMINUS1Z
E1
NR SUBFILE
R1
TBOTTLES
R1
TBLANK
R1
TBOB
R1
TBLANK
R1
TOTW
R1
TCOMMA
E2
NR SUBFILE
R2
TBOTTLES
R2
TBLANK
R2
TBOB
R2
TCOMMA
E3
NR SUBFILE
R3
TTOD
R3
TCOMMA
R3
TBLANK
R3
TPIA
R3
TCOMMA
E4
NR SUBFILE
R4
TMINUS1
R4
TBLANK
R4
TBOB
R4
TBLANK
R4
TOTW
R4
TPERIOD
E5
NR SUBFILE
R5
TBLANK
S
100
TBOTTLESZ
S
TMINUS1Z
TBOTTLES
TMINUS1
V
V
V
V
V
ISM/SML
SML is the language used in ISM/Openmaster, the BULL Administrative Platform. ISM/SML
(for Integrated System Management / System Management Language).
; Code Begin
; A.Brunet@frcl.bull.fr (Alain Brunet)
(defun beer(cap)
(dotimes (i cap)
(print (- cap i) " bottle" (if (= i (- cap 1)) "" "s") " of beer on
the wall.")
(print "Take one down, pass it around.\n")
)
(print "Time to buy more beer !")
)
(beer 99)
Korn Shell
Yet another UN*X shell.
#!/bin/ksh
# Korn shell version of 99 Bottles
# Dave Plonka - plonka@carroll1.cc.edu
typeset -i n=99
typeset bottles=bottles
typeset no
while (( n ))
do
print "${n?} ${bottles?} of beer on the wall,"
print "${n?} ${bottles?} of beer,\ntake one down, pass it around,"
n=n-1
case ${n?} in
0)
no=no
bottles=${bottles%s}s
;;
1)
bottles=${bottles%s}
;;
esac
print "${no:-${n}} ${bottles?} of beer on the wall.\n"
done
exit
LabVIEW
An icon based language. Click for more information
Leda
Leda is a multiparadigm programming language designed by Timothy A. Budd. It supports
imperative, object-oriented, functional and logic programming paradigms. Click here for
Information and an interpreter.
{ 99 bottles of beer, Leda version
{ By Arion Lei (philipl@cs.ust.hk)
}
}
include "std.led";
const
verse1 := " bottles of beer on the wall,\n";
verse2 := " bottles of beer. Take one down, pass it around,\n";
verse3 := " bottles of beer on the wall.\n";
verse4 := "No more bottles of beer on the wall, no more bottles of
beer.\n";
verse5 := "Go to the store and buy some more... 99 bottles of
beer.\n\n";
{ ========== IMPERATIVE PROGRAMMING =========== }
function proc_Beer (bottleTotal : integer);
var bottleLeft : integer;
begin
bottleLeft := bottleTotal;
while bottleLeft0 do begin
print(bottleLeft); print(verse1);
print(bottleLeft); print(verse2);
bottleLeft := bottleLeft - 1;
if (bottleLeft0) then begin
print(bottleLeft); print(verse3);
end;
end;
print(verse4);
print(verse5);
end; { proc_Beer }
{ ========== OBJECT-ORIENTED PROGRAMMING =========== }
class Beers;
var
bottleLeft : integer;
function more () - boolean;
begin
return bottleLeft > 0;
end;
function consume1 ();
begin
print(bottleLeft); print(verse1);
print(bottleLeft); print(verse2);
bottleLeft := bottleLeft - 1;
if (bottleLeft0) then begin
print(bottleLeft); print(verse3);
end else begin
print(verse4);
print(verse5);
end;
end;
end; { class Beers }
function obj_Beer (bottleTotal : integer);
var obeer : Beers;
begin
obeer := Beers(bottleTotal);
while (obeer.more()) do obeer.consume1();
end; { obj_Beer }
{ ========== FUNCTIONAL PROGRAMMING =========== }
function func_Beer (num : integer) - function();
begin
return function ();
begin
print(num); print(verse1);
print(num); print(verse2);
if num1 then begin
print(num-1); print(verse3);
func_Beer(num-1)();
end else begin
print(verse4);
print(verse5);
end;
end;
end; { func_Beer }
{ ========== LOGIC PROGRAMMING =========== }
function log_Beer (bottleTotal : integer);
function pickBottle (byRef left : integer, total : integer)-relation;
begin
if total = 0 then
return false
else
return left relation;
begin
print(i); print(verse1);
print(i); print(verse2);
if i1 then begin
print(i-1); print(verse3);
end else begin
print(verse4);
print(verse5);
end;
return true;
end;
var i : integer;
begin
for pickBottle(i, bottleTotal) & consume(i) do begin end;
end; { log_Beer }
{ ---------- MAIN PROGRAM ---------- }
var bottleTotal : integer;
begin
bottleTotal := 99;
proc_Beer (bottleTotal);
obj_Beer (bottleTotal);
func_Beer(bottleTotal)();
log_Beer(bottleTotal);
end;
Limbo
Limbo is compiler for Lucent Technologies new Inferno Operating System.
implement BeerBottles;
include "sys.m";
sys: Sys;
include "draw.m";
draw: Draw;
BeerBottles: module
{
init: fn(ctxt: ref Draw-Context, agv: list of string);
};
init(ctxt: ref Draw-Context, argv: list of string)
{
sys = load Sys Sys-PATH;
for (int bottles = 99; bottles > 0; bottles--) {
sys-print("%d bottle(s) of beer on the wall,\n",bottles);
sys-print("%d bottle(s) of beer.\n",bottles);
sys-print("Take one down, pass it around,\n");
sys-print("%d bottle(s) of beer on the wall.\n\n");
}
}
M-Speak
M-Speak is a word-processing macro language created in the late 1970's for the Spellbinder
word processor.
;-)
Spellbinder Macro to print "99 Bottles of Beer on the Wall"
(-;
; by Andy Goldberg
;
:%A="s"
;set variable for plural
:%1=99
;initialize counter
:%2=%1-1
;decrement at top of loop
s//%1 bottle%A of beer on the wall</
;lyric
s//%1 bottle%A of beer</<
s//Take one down and pass it around</
:on %2-1 /+4 / /+1
:%A=""
plural
s//%2 bottle%A of beer on the wall.<</
:%1=%1-1
:on -1 /-9
s//No more bottles of beer on the wall.</
/t/p/wo/song.txt/t/gd
(optional)
;check for last stanza
;if last stanza clear
;last line and blank line
;check for end
;if not end then loop
;ending line
;print, save and end
MetaPost
For more information on MetaPost see http://cm.bell-labs.com/who/hobby/MetaPost.html
% MetaFont/MetaPost version of ``99 bottles'' by Tomasz J. Cholewo
% For more information see http://cm.bell-labs.com/who/hobby/MetaPost.html
for i:=99 downto 1:
message decimal i & " bottle" if i1: & "s" fi & " of beer on the wall,";
message decimal i & " bottle" if i1: & "s" fi & " of beer.";
message "Take one down, pass it around.";
endfor;
message "No more bottles of beer on the wall.";
end
ILE AS/400
This is IBM's next generation of RPG.
H*
H* ILE RPG/400 - 99 Bottles of Beer on the Wall.
H* (IBM AS/400 Midrange Platform)
H* (Program Source BOTTLESR1)
H*
FBottlesS1 O
E
WorkStn
C
C
Z-Add
*HIVAL
Bottles1
C
C
DoW
Bottles1 *Zero
C
Eval
Bottles2 = Bottles1
C
Write
#Display
C
Sub
1
Bottles1
C
EndDo
C
C
Eval
*InLR = *On
C
----------------------A*
A*
A*
A*
A*
A
A
A
A
A
A
A
A
A
ILE RPG/400 - 99 Bottles of Beer on the Wall.
(IBM AS/400 Midrange Platform)
(Display File Source BOTTLESS1)
DSPSIZ(24 80 *DS3)
FRCDTA
R #DISPLAY
BOTTLES1
2Y 0O
BOTTLES2
2Y 0O
4 2EDTCDE(4)
4 5'Bottles of Beer On the Wall,'
4 34EDTCDE(4)
4 37'Bottles of Beer,'
5 2'Take one down, pass it around.'
MPTMON
; MPTMON (Multi Processor Test Monitor) is a debugging
; tool for telephonic exchanges from Alcatel.
; These two macros do the beer job..
REM MAC Bottle
DEF MAC Bottle
WR %0,' Bottle',&
IF %0<>1\'s',&
END
' of Beer',&
IF %1\' on the Wall',&
END
'%2'
EM
REM MAC Beer
DEF MAC Beer ; jr_31jan97
ADD SYM.I=99T
BAS=T
COU 99T
Bottle:.I,TRUE,','
Bottle:.I,FALSE,'.'
'
Take one down, pass it around,'
.I=.I-1
Bottle:.I,TRUE,'.'
''
END
EM
Beer:
Model 204
*Model 204 (or M204 as it's commonly called) is a proprietary
*database and language of Computer Corporation of America.
*It was first developed over 30 years ago by the NSA.
*Some claim that it's the fastest IBM Mainframe database.
*It is good for databases with large record counts.
*The Department of Social Security of Australian employs
*hundreds of M204 programmers.
*Add-on packages permit SQL and Web access.
*
* Written by Kevin Giles, NCI Information Systems Inc.
* e-mail: KGILES@USGS.GOV
*
* 100 bottles of beer / take one / action
*
*LOWER
BEGIN
DECLARE %S IS STRING LEN 1 COMMON
FOR %BOTTLE FROM 100 TO 0 BY -1
CALL CHECKPLURAL(%BOTTLE)
PRINT %BOTTLE AND 'bottle' WITH %S AND 'of beer on the wall.'
PRINT %BOTTLE AND 'bottle' WITH %S AND 'of beer.'
PRINT 'Take one down, pass it around.'
CALL CHECKPLURAL(%BOTTLE-1)
IF %BOTTLE-1 = +0 THEN PRINT 'No bottles of beer on the wall.'
SKIP 1 LINE
PRINT 'No bottles of beer on the wall.'
PRINT 'No bottles of beer.'
PRINT 'Go to the store, buy some more.'
%BOTTLE = 101
CALL CHECKPLURAL(%BOTTLE-1)
END IF
PRINT $UNBLANK(%BOTTLE-1) AND 'bottle' WITH %S AND 'of beer on the wall.'
SKIP 1 LINE
END FOR
SUBROUTINE CHECKPLURAL (%PASSVAL STRING DP 0 INPUT)
IF %PASSVAL NE +1 THEN %S = 's'
ELSE
%S = ''
END IF
END SUBROUTINE
END
Miranda
|| 99 bottles of beer in Miranda - the hideous functional programming
lingo
|| by Tim Walls, tjw1@doc.ic.ac.uk, http://www-
students.doc.ic.ac.uk/~tjw1/
||
|| Call with 'bottlesofbeer 99'.
bottlesofbeer :: num -> [char]
bottlesofbeer n = "\nNo more bottles of beer on the wall, \n"
++ "no more bottles of beer.\n" , if n = 0
= "\nOne more bottle of beer on the wall, one bottle of
beer,\n"
++ "Take one down and pass it around"
++ (bottlesofbeer (n-1))
, if n = 1
= "\n" ++ shownum(n) ++ " bottles of beer on the wall,"
++ shownum(n)
++ " bottles of beer,\nTake one down and pass it
around"
++ (bottlesofbeer (n-1))
, otherwise
K
s:" bottles of beer on the wall, bottles of beer.
If bottles should happen to fall,
bottles of beer on the wall.
"
d:{`0:,/|(r[];u[]),n'|3_!x+1}
r:{k[(1;1;"that";"No more")]_di 8 39 64}
u:{n[2]_di 105}
n:{k(x;x;"one of those";x-1)}
k:{,/($x),'0 30 51 83_ s}
Lakota
Lakota is a shell language used mainly in the TRUEchange configuration management
package from True Software. Code courtesy Beirne "Bern" Konarski.
#! /usr/local/lsh
set-string s s
set-string item one
do i 99 1 -1
print (i) bottle(s) of beer on the wall,
print (i) bottle(s) of beer.
print You take (item) down, pass it around,
set-string j {- (i) 1}
if {=? (j) 1}
set-string s
set-string item it
if {=? (i) 1}
print No more bottles of beer on the wall.(newline)
else
print (j) bottle(s) of beer on the wall.(newline)
cycle
Luck
Luck is custom programming language. 99BoB code contributed by the creator.
luck: Beer99
proc: main
new #bottles = 99
loop: #bottles 0
saysolo #bottles
say " bottle(s) of beer on the wall."
saysolo
#bottles
say " bottle(s) of beer."
say "Take one down and pass it
around."
#bottles = #bottles - 1
if: #bottles = 0
saysolo "No
more"
end
if: #bottles 0
saysolo #bottles
end
say "
bottle(s) of beer on the wall."
say
end
end
Magma
Magma is a computer algebra system from Australia.
verse := function(n)
bottles := function(n)
return n eq 1 select "1 bottle"
else IntegerToString(n) cat " bottles";
end function;
return current cat " of beer on the wall,\n" cat
current cat " of beer;\n" cat
"Take one down, pass it around,\n" cat
bottles(n - 1) cat " of beer on the wall.\n\n"
where current is bottles(n);
end function;
song := procedure()
print &cat [verse(n) : n in [99 .. 1 by -1]] cat
"Go to the store and get some more.";
end procedure;
Jam
Jam is a make-like system for building programs, etc.
# Jamfile for 99 Bottles of beer on the wall.
# David Brandon (brandon@aspentech.com)
ALWAYS beer ;
rule Drink {
for tenbeers in 9 8 7 6 5 4 3 2 1 "" {
for beers in 9 8 7 6 5 4 3 2 1 0 {
b = $(tenbeers)$(beers) ;
if ( $(b) != 99 ) {
ECHO "$(b) bottles of $(
Navel
# Bottles of beer in Navel
Greg Michaelson
greg@cee.hw.ac.uk #
def itos n = if n=0 then "0" else itos1 "" n;
def itos1 l n = if n=0 then l else itos1 (char (n%10+'0')):l n/10;
def verse n = {(itos n) " bottle(s) of beer on the wall\n"
(itos n) " bottle(s) of beer on the wall\n"
"Take one down and pass it around\n"
(itos n-1) " bottle(s) of beer on the wall\n"};
def verses n =
if n=0
then ()
else
let v = write (?(verse n))
in verses n-1;
Postscript
Postscript has two significant "modes." One is interactive, the other is document
printing/typesetting. Belows are samples of both kinds of code.
% How to do 99 Bottles of Beer in Postscript.
% This doesn't go out to the printer. You'd need to hook a serial port
% to your LaserPrinter or Postscript typesetter
/beer {
/bottles 7 string def
99 -1 1
{ dup bottles cvs print ( bottles of beer on the wall, )
bottles print (bottles of beer. Take one down, pass it around, )
1 sub bottles cvs print ( bottles of beer on the wall. )
} for
(No more bottles of beer on the wall, no more bottles of beer. )
(Go to the store and buy some more... 99 bottles of beer) } def
Pascal
(* Pascal version of 99 Bottles of beer *)
program BottlesOfBeers(input, output);
var
bottles: integer;
begin
bottles := 99;
repeat
WriteLn(bottles, ' bottles
bottles, ' bottles
Write('Take one down, pass
bottles := bottles-1;
WriteLn(bottles, ' bottles
until (bottles = 1);
WriteLn('1 bottle of beer on
WriteLn('Take one down, pass
' no more bottles of
end.
of beer on the wall, ',
of beer.');
it around, ');
of beer on the wall.');
the wall, one bottle of beer.');
it around,'
beer on the wall')
---- Printable version ---%!PS
% The 99 bottles of beer song in PostScript. This file
% can be sent to a PostScript printer (it'll be about
% eight pages or so...)
% Stuart Morris
% ------------- Variables & Procedures -----------/LM 72 def
/ypos 720 def
/BM 72 def
/lineheight 18 def
%
%
%
%
left margin
initial top position
bottom margin
height of a line of text
% starts a new line
/crlf
{
ypos lineheight sub
/ypos exch def
LM ypos moveto
} def
% starts a new page if current one is full
/newpage?
{
ypos BM lt
{
showpage
/ypos 720 def
LM ypos moveto
} if
} def
% returns the correct syntax of the bottle
% string ("bottle" if one, "bottles" otherwise)
/bottlestring % stack: number of bottles
{
1 eq
{
( bottle of beer)
}
{
( bottles of beer)
} ifelse
} def
% ------------- Main Program ---------------LM ypos moveto
/Times-Roman findfont
lineheight 2 sub scalefont
setfont
99 -1 1
{
/numbottles 2 string def
dup numbottles cvs show
dup bottlestring show ( on the wall, ) show
numbottles show dup bottlestring show (,) show
crlf
(Take one down, pass it around, ) show
1 sub dup numbottles cvs show
bottlestring show ( on the wall.) show
crlf crlf
newpage?
} for
showpage
REXX
/* Rexx Version of the Bottles program */
/* by Lee Stewart (ls@sweng.stortek.com) */
Trace Off;
Do Forever;
Do i = 99 To 1 By -1;
If i > 1 Then pl = 's';
Else pl = '';
Say i 'bottle'pl 'of beer on the wall,' i 'bottle'pl 'of beer';
Say 'Take one down, pass it around';
End;
Say 'No more bottles of beer on the wall, no more bottles of beer';
Say 'Go to the store and buy some more';
End;
PL/I
/* And here is the PL/I version: */
BOTTLES: PROC OPTIONS(MAIN);
DCL
DCL
DCL
DCL
NUM_BOT
PHRASE1
PHRASE2
PHRASE3
FIXED DEC(3);
CHAR(100) VAR;
CHAR(100) VAR;
CHAR(100) VAR;
DO NUM_BOT = 100 TO 1 BY -1;
PHRASE1 = NUM_BOT||' Bottles of Beer on the wall,';
PHRASE2 = NUM_BOT||' Bottles of Beer';
PHRASE3 = 'Take one down and pass it around';
DISPLAY(PHRASE1||PHRASE2);
DISPLAY(PHRASE3);
END;
PHRASE1 = 'No more Bottles of Beer on the wall, ';
PHRASE2 = 'No more Bottles of Beer';
PHRASE3 = 'Go to the store and buy some more';
DISPLAY(PHRASE1||PHRASE2);
DISPLAY(PHRASE3);
END BOTTLES;
RPG/400
H*
H* RPG/400 VERSION OF THE BOTTLES PROGRAM *
H*
FSCREEN O
F
80
WORKSTN
C
MOVE 100
X
C
X
DOWGE0
C
EXCPT
C
SUB 1
X
C
END
C
SETON
30
LR
OSCREEN
O
O
O
O
O
O
O
O
E
X
X
3
26 'BOTTLES OF BEER ON THE'
31 'WALL,'
36
53 'BOTTLES OF BEER'
E
22 'TAKE ONE DOWN AND PASS'
32 'IT AROUND'
Python
#!/usr/local/bin/python
#
python version of 99 bottles of beer, compact edition
#
by Fredrik Lundh (fredrik_lundh@ivab.se)
def bottle(n):
try:
return { 0: "no more bottles",
1: "1 bottle"} [n] + " of beer"
except KeyError: return "%d bottles of beer" % n
for i in range(99, 0, -1):
b1, b0 = bottle(i), bottle(i-1)
print "%(b1)s on the wall, %(b1)s,\n"\
"take one down, pass it around,\n"\
"%(b0)s on the wall." % locals()
Perl
The second one is intended to be the author's .sig for his email.
#! /usr/bin/perl
# Jim Menard
jimm@{bbn,io}.com
(617) 873-4326
http://www.io.com/~jimm/
$nBottles = $ARGV[0];
$nBottles = 100 if $nBottles eq '' || $nBottles < 0;
foreach (reverse(1 .. $nBottles)) {
$s = ($_ == 1) ? "" : "s";
$oneLessS = ($_ == 2) ? "" : "s";
print "\n$_ bottle$s of beer on the wall,\n";
print "$_ bottle$s of beer,\n";
print "Take one down, pass it around,\n";
print $_ - 1, " bottle$oneLessS of beer on the wall\n";
}
print "\n*burp*\n";
Signature version
#!/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
Prolog
/*
99 bottles of beer in Prolog
Rob van de Pol
R.vandePol@voeding.tno.nl
TNO Nutrition and Food Research Institute
The Netherlands
*/
domains
count = integer
predicates
bottles(count)
clauses
bottles(1) :write ("1 bottle of beer on the wall, 1 bottle of beer,\n"),
write ("Take one down, and pass it around,\n"),
write ("Now they are alle gone.").
bottles(X) :write ( X , " bottles of beer on the wall, " ,
X , " bottles of beer,\n"),
write ("Take one down, and pass it around,\n"),
X1 = X - 1,
write ( X1 , " bottles of beer on the wall.\n",
bottles(X1).
goal
bottles(99)
NROFF
nroff is a text formatting macro language common under UNIX
.\" Tim Goodwin <tim@pipex.net>
.nr BO 99
.de BP
.if \\n(BO=0 No more
.if !\\n(BO=0 \\n(BO
.if \\n(BO=1 bottle
.if !\\n(BO=1 bottles
of beer
..
.de WP
.BP
on the wall
..
.de BE
.WP
.br
.BP
.br
Take one down, pass it around
.br
.nr BO \\n(BO-1
.WP
.sp
.if \\n(BO0 .BE
..
.BE
Prograph
Click for more info.
Oberon
MODULE BottlesOfBeers; (* Andrejs Jansons 27.10.95 *)
IMPORT Out;
PROCEDURE Start*;
VAR
bottles: INTEGER;
BEGIN
bottles := 99;
REPEAT
Out.Int(bottles, 2);
Out.String(" bottles of beer on the wall, ");
Out.Int(bottles, 2);
Out.String(" bottles of beer.");
Out.Ln;
Out.String("Take one down, pass it around, ");
DEC(bottles);
Out.Int(bottles, 2);
Out.String(" bottles of beer on the wall.");
Out.Ln
UNTIL bottles = 1;
Out.String("1 bottle of beer on the wall, one bottle of
beer.");
Out.Ln;
Out.String("Take one down, pass it around,");
Out.String(" no more bottles of beer on the wall");
Out.Ln
END Start;
END BottlesOfBeers.
This is a noteworty Object Oriented version in Oberon:
MODULE BeerSong;
(* An object-oriented beer song in Oberon-2
*)
(* Contributed by Michael Griebling (mgriebling@bix.com) *)
IMPORT O:=Out;
TYPE
WallObject* = RECORD beer-: SHORTINT END;
VAR
BeerWall : WallObject;
PROCEDURE (VAR wall: WallObject) LineEmUp*;
BEGIN wall.beer := 99
END LineEmUp;
PROCEDURE (VAR wall: WallObject) PassOneAround*;
BEGIN DEC(wall.beer)
END PassOneAround;
PROCEDURE (VAR wall: WallObject) HasMoreBeer* () : BOOLEAN;
BEGIN RETURN wall.beer > 0
END HasMoreBeer;
PROCEDURE SingOf(beer: SHORTINT);
BEGIN
IF beer = 0 THEN O.String("No more") ELSE O.Int(beer, 1) END;
O.String(" bottle"); IF beer#1 THEN O.Char("s") END; O.String(" of
beer")
END SingOf;
PROCEDURE (VAR wall: WallObject) SingVerse*;
BEGIN
SingOf(wall.beer); O.String(" on the wall, "); SingOf(wall.beer);
O.Ln;
O.String("Take one down and pass it around,"); O.Ln;
SingOf(wall.beer-1); O.String(" on the wall."); O.Ln; O.Ln
END SingVerse;
BEGIN
BeerWall.LineEmUp;
WHILE BeerWall.HasMoreBeer() DO BeerWall.SingVerse;
BeerWall.PassOneAround END
END BeerSong.
Pop
define beer(n);
define :inline PLURAL(N);
(N==1 and nullstring or "s")
enddefine;
lvars i;
for i from n by -1 to 1 do;
nl(1);
nprintf(PLURAL(i), i, '%P bottle%P of beer on the wall.');
nprintf(PLURAL(i), i, '%P bottle%P of beer!');
nprintf(i==1 and "it" or "one", 'Take %P down, pass it around.');
if i1 then
nprintf(PLURAL(i-1), i-1, '%P more bottle%S of beer on the
wall.');
else
npr('No more bottles of beer on the wall.');
endif;
endfor;
enddefine;
beer(100);
Progress
Progress is a database system that is used to create enterprise database solutions.
/* Progress 4GL version of 99 Bottles of Beer.
* programmer: Rich Uchytil rich@cray.com
* 10/30/95
*/
def var i as int no-undo format "z9".
do i = 99 to 1 by -1:
disp i "bottles of beer on the wall," skip
i @ x as int format "z9" "bottles of beer" skip
"Take one down and pass it around," skip
i - 1 format "z9" "bottles of beer on the wall."
with no-labels no-box no-attr 1 down.
pause 1 no-message. /* needed otherwise it would run too fast */
end.
Pilot
R: PILOT version of 99 Bottles of Beer
: hacked by Akira KIDA, <SDI00379@niftyserve.or.jp>
C:BOTTLES=99
U:*BEERS
*LOOP
T:$T of beer on the wall, $T.
T:Take one down, pass it around.
C:BOTTLES=BOTTLES-1
U:*BEERS
T:$T on the wall.
T:
J(BOTTLES0):*LOOP
E:
*BEERS
C(BOTTLES=0):$T=No more bottles
C(BOTTLES=1):$T=1 bottle
C(BOTTLES1):$T=#BOTTLES bottles
E:
PV-Wave
PV-Wave, also known as IDL, is a language designed for visual data analysis.
;
; 99 bottles of beer
; V1
; Author: George M.Sigut (sigut@bs.id.ethz.ch)
;
; yes, I DO know the second loop could be unrolled
;
ninety_nine = 99
texta = ' bottles of beer'
textb = ' bottle of beer'
textf = ' no more'
;
number1 = strcompress(string(ninety_nine))
text1
= texta
number2 = strcompress(string(ninety_nine-1))
text2
= texta
for i=ninety_nine,3,-1 do begin &$
print,number1,text1,' on the wall' &$
print,number1,text1 &$
print,' you take one down & pass it around' &$
print,number2,text2 &$
print &$
number1 = number2 &$
number2 = strcompress(string(i-2)) &$
endfor
;
text1 = texta
text2 = textb
for i=2,1,-1 do begin &$
print,number1,text1,' on the wall' &$
print,number1,text1 &$
print,' you take one down & pass it around' &$
print,number2,text2 &$
print &$
number1 = number2 &$
text1
= textb &$
number2 = textf &$
text2
= texta &$
endfor
;
;
---------- Variant more in keeping with the language's style -----
;
; 99 bottles of beer
; V2
;
ninety_nine = 99
texta = ' bottles of beer'
textb = ' bottle of beer'
textf = ' no more'
;
full_text = strarr(1,4,ninety_nine)
;
full_text(0,1,*) = strcompress(string(ninety_nine-indgen(ninety_nine))) +
texta
full_text(0,0,*) = full_text(0,1,*) + ' on the wall'
full_text(0,2,*) = ' you take one down & pass it around'
full_text(0,3,0:ninety_nine-2)=full_text(0,1,1:ninety_nine-1)
;
full_text(0,3,ninety_nine-2) = strcompress(1)+textb
full_text(0,0,ninety_nine-1) = full_text(0,3,ninety_nine-2)+' on the wall'
full_text(0,1,ninety_nine-1) = full_text(0,3,ninety_nine-2)
full_text(0,3,ninety_nine-1) = textf+texta
;
print,full_text
;
Natural
* PGM-ID: BEER
* AUTHOR: CHRIS BEDNARA
* COMMENT: NATURAL '99 BOTTLES OF BEER ON THE WALL' CODE
*
*------------------------------------------------------DEFINE DATA
LOCAL
01 #BOTTLES (I2)
END-DEFINE
*
FOR #BOTTLES 99 TO 2 STEP -1
IF #BOTTLES < 98
WRITE #BOTTLES ' BOTTLES OF BEER ON THE WALL'
WRITE ' '
END-IF
*
WRITE #BOTTLES ' BOTTLES OF BEER ON THE WALL'
WRITE #BOTTLES ' BOTTLES OF BEER'
WRITE 'TAKE ONE DOWN, PASS IT AROUND'
END-FOR
*
WRITE '1 BOTTLE OF BEER ON THE WALL'
WRITE ' '
WRITE '1 BOTTLE OF BEER ON THE WALL'
WRITE '1 BOTTLE OF BEER'
WRITE 'TAKE IT DOWN, PASS IT AROUND'
WRITE 'NO MORE BOTTLES OF BEER ON THE WALL'
WRITE ' '
WRITE
WRITE
WRITE
WRITE
END
WRITE
'NO
'NO
'GO
'99
MORE BOTTLES OF BEER ON THE WALL'
MORE BOTTLES OF BEER'
TO THE STORE AND BUY SOME MORE'
BOTTLES OF BEER'
'TAKE ONE DOWN, PASS IT AROUND'
NIAL
Nial stands for Nested Interactive Array Language, which incorporates ideas from APL2,
Lisp, FP and structured programming. Q'Nial is a Nial programming system developed at
Queen's University in Canada Click here for more info.
% Nial (Q'Nial) version of 99 bottles of beer
%;
% loaddef "beer;
% beer 99;
%;
% Hacked by Akira KIDA, SDI00379@niftyserve.or.jp;
bottles IS OPERATION A {
IF A = 0 THEN
'No more bottles'
ELSEIF A = 1 THEN
link (sketch A) ' bottle'
ELSE
link (sketch A) ' bottles'
ENDIF
}
beer IS OPERATION A {
FOR x WITH reverse count A DO
write link (bottles x) ' of beer on the wall, '
(bottles x) '.';
write 'Take one down, pass it around.';
write link (bottles (x - 1)) ' of beer on the wall.';
write '';
ENDFOR;
}
OPL
OPL (Organiser Programming Language) is the language used by Psion palmtops.
REM ********************************************************************
REM *
99 Bottles of Beer
*
REM
REM
REM
REM
REM
REM
REM
REM
REM
*
*
* A portable version for those who need this vital application
*
* with them at all times. The following is written in Psion OPL,
*
* the language used in the popular Series 3 and Series 3a palmtops *
* (and other previous Psion products).
*
*
*
* by Dave Wilson, dawilson@brooktree.com
*
*
*
********************************************************************
PROC Main:
LOCAL bottles%
LOCAL bottle$(10)
CLS
bottles%=99
bottle$=" bottles"
PRINT "99 Bottles of Beer"
PRINT
WHILE(bottles% > 0)
PRINT bottles%;bottle$;" of beer on the wall,"
PRINT bottles%;bottle$;" of beer on the wall."
PRINT "Take one down and pass it around,"
bottles%=bottles%-1
IF(bottles% = 1)
bottle$=" bottle"
ENDIF
IF(bottles% <> 0)
PRINT "There'll be ";bottles%;bottles$;" of beer on the wall."
ELSE
PRINT "There'll be no bottles of beer on the wall."
ENDIF
PRINT
ENDWH
PAUSE 0
ENDP
NEWLIB
NEWLIB is a programming aid that operates as a command processor in the Time Sharing
Option (TSO) environment. (Mostly based on PL/I, therefore the similarity.) It is used at
DESY/Hamburg and KEK/Tsukuba.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$
21/02/96 602211216 MEMBER NAME <<EDTCL (SPECTRUM)
CLIST
$ NEWLIB VERSION OF 99 BOTTLES OF BEER
$ R.P.HOFMANN F15RPH@DSYIBM.DESY.DE
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
STORE
ESC := '%'
DO N0 = 1 TO 99
N1 := 100-%N0
IF N1 > 1 THEN
IF N0 > 1 SHOW N1||' BOTTLES OF BEER ON THE WALL'
SHOW N1||' BOTTLES OF BEER ON THE WALL'
SHOW N1||' BOTTLES OF BEER'
ELSE
SHOW '1 BOTTLE OF BEER ON THE WALL'
SHOW '1 BOTTLE OF BEER ON THE WALL'
SHOW '1 BOTTLE OF BEER'
ENDIF
SHOW 'TAKE 1 DOWN AND PASS IT ALL AROUND'
END
SHOW '0 BOTTLES OF BEER ON THE WALL'
RESTORE
Posix
Posix is yet another U**x shell.
#!/bin/sh
# POSIX shell version of 99 Bottles
# Dave Plonka - plonka@carroll1.cc.edu
typeset -i n=99
typeset bottles=bottles
typeset no
while let n
do
echo "${n?} ${bottles?} of beer on the wall,"
echo "${n?} ${bottles?} of beer,"
echo "take one down, pass it around,"
n=n-1
case ${n?} in
0)
no=no
bottles=${bottles%s}s
;;
1)
bottles=${bottles%s}
;;
esac
echo "${no:-${n}} ${bottles?} of beer on the wall."
echo
done
exit
Quick Basic
'99 Bottles of Beer on the Wall
'Patrick Fleming
http://chem-www.mps.ohio-state.edu/~pfleming/
CLS
n = 100
DO UNTIL n = 1
n = n - 1
PRINT n; "bottle";
IF n <> 1 THEN PRINT "s";
PRINT " of beer on the wall . . ."
PRINT n; "bottle";
IF n <> 1 THEN PRINT "s";
PRINT " of beer!"
PRINT "Take one down, pass it around . . ."
PRINT n - 1; "bottle";
IF n - 1 <> 1 THEN PRINT "s";
PRINT " of beer on the wall!"
PRINT
LOOP
END
Rapid
Rapid is a a prototyping language developed by Emultek. There were several screen shots
associated with this, but this one is the most obviously the programming language part of it.
PAL
PAL is Prodigy Application Language. I listed this one as unique simply because you don't
often get a peek at a truly proprietary language. This can't be compiled by anyone other than
Prodigy employees.
/*========================================================================
=*/
/*
*/
/*
PRODIGY SERVICES COMPANY
*/
/*
*/
/* Author:
Kim Moser (kmoser@prodigy.com)
*/
/* Application:
99 Bottles of Beer on the Wall
*/
/* Program Name: XXXXBEER.PGM
*/
/* Program Type: Element preprocessor
*/
/* File Name:
xxxxbeer.s
*/
/* Version:
0.0
*/
/* Contents:
PAL
*/
/*========================================================================
=*/
/* PROGRAM DESCRIPTION: This function fills PEVs 10-110 with 99 verses
*/
/* of the "99 Bottles of Beer on the Wall" song (one verse per PEV),
*/
/* appends these verses to the file whose name was given in P1 (the
*/
/* first parameter), then opens a window warning you to buy more beer.
*/
/*
*/
/* The program is smart enough to pluralize "beer" when refering to
*/
/* more than one, and says "no" when refering to 0 bottles.
*/
/*
*/
/* The output is as follows:
*/
/* 99 bottles of beer on the wall, 99 bottles of beer.
*/
/* Take one down, pass it around, 98 bottles of beer on the wall.
*/
/* ...
*/
/* 1 bottle of beer on the wall, 1 bottle of beer.
*/
/* Take one down, pass it around, no bottles of beer on the wall.
*/
/* Time to buy more beer!
*/
/*
*/
/*------------------------------------------------------------------------
-*/
/* MAINTENANCE LOG:
*/
/* PROGRAMMER
DATE
DESCRIPTION OF CHANGE
*/
/*
Kim Moser
23-Oct-96
Creation.
*/
/*========================================================================
=*/
#define DISPLAY_PEV
10
#define Q_CTX_NAME "beer_ctx"
context beer_ctx {
var
ctx_fp,
/*
ctx_bottle,
/*
ctx_bottle_of_beer,
/*
ctx_bottles_of_beer,
/*
ctx_on_the_wall;
/*
}
#define DEFAULT_FNAME
File pointer: where to write the song */
" bottle" */
" bottle of beer" */
" bottles of beer" */
" on the wall" */
"beer.txt"
"XXXXBEERPGM\00\0C"(var fname)
{
var i;
var of_beer;
var sentence;
if (open_one_context(Q_CTX_NAME)
/* Error opening context */
return (-1);
}
1) {
/* Initialize context: */
/* Reduce string overhead by putting these phrases in variables: */
of_beer = " of beer";
ctx_bottle = " bottle";
ctx_bottle_of_beer = string(ctx_bottle, of_beer);
ctx_bottles_of_beer = string(ctx_bottle, "s", of_beer);
ctx_on_the_wall = " on the wall";
if (fname ==$ "") {
/* No filename specified */
fname = DEFAULT_FNAME;
}
if (open(fname, F_APPEND, ctx_fp) == 0) {
for (i=99; i 0; i-=1) {
sentence = bottles_sentence(i);
&0[DISPLAY_PEV + (100-i)] = sentence;
write_line(ctx_fp, sentence);
}
write_line(ctx_fp, "Time to buy more beer!\n");
close(ctx_fp);
}
close_all_contexts(Q_CTX_NAME);
open_window("XXXXBEERWND\00\0E");
/* Warning: Time to buy more beer
*/
}
bottles_sentence(var n_bottles)
{
var bob1, bob2; /* " bottles of beer" or " bottle of beer" */
bob1 = bob(n_bottles);
bob2 = bob(n_bottles - 1);
return (
string(
n_bottles,
bob1,
ctx_on_the_wall,
", ",
n_bottles,
bob1,
".\nTake one down, pass it around, ",
(n_bottles-1 ? n_bottles-1 : "no"),
bob2,
ctx_on_the_wall,
"."
)
);
}
bob(var n_bottles)
{
return (n_bottles==1 ? ctx_bottle_of_beer : ctx_bottles_of_beer);
}
PLEX
PLEX (Programming Language for EXchanges) is a real-time language developed in 1970
by Ericsson to program telephony exchanges.
! The main program "99 bottles ..." programmed in PLEX
! Programmer Staale Andersen
etosta@eto.ericsson.se
!
!
! Comment: The need for an own parameterlist and a signal survey, !
! leads to the whole beer program beeing in 3 parts.
!
DOCUMENT BEERPROGRAM;
DECLARE;
GLOBAL NSYMB COCA99 (#FFFF);
GLOBAL STRING BEERS (7);
STRING VARIABLE ONWALL1 31 DS;
STRING VARIABLE ONWALL2 63 DS;
STRING VARIABLE BOTTLES 31 DS;
STRING VARIABLE TAKEDOWN 63 DS;
VARIABLE CBEER 16 DS;
VARIABLE CIOID 16 DS;
VARIABLE TIOID 16;
VARIABLE TSTARTPHASE 16;
VARIABLE TSIGNALKEY 16;
VARIABLE TBLOCKINFO 16;
END DECLARE;
PROGRAM BEERPROGRAM;
PLEX;
ENTER STTOR WITH
+,
TSTARTPHASE,
+,
+,
+,
+,
TSIGNALKEY;
TBLOCKINFO = #100;
SEND STTORRY
WITH
TSIGNALKEY,
TBLOCKINFO,
5,
255;
EXIT;
COMMAND BEERS TYPE COCA99,
ID IS TIOID;
CIOID = TIOID;
ONWALL1 = " BOTTLES OF BEER ON A WALL, ";
ONWALL2 = " BOTTLES OF BEER ON A WALL.";
BOTTLES = " BOTTLES OF BEER";
TAKEDOWN = "TAKE ONE DOWN AND PASS IT AROUND, ";
ON CBEER FROM 99 DOWNTO 1 DO
CASE CBEER IS
WHEN 1 DO
BOTTLES = " BOTTLE OF BEER";
ONWALL1 = " BOTTLE OF BEER ON A WALL, ";
ONWALL2 = "NO MORE BOTTLES OF BEER ON A WALL.";
WHEN 2 DO
ONWALL2 = " BOTTLE OF BEER ON A WALL.";
OTHERWISE DO;
ESAC;
INSERT VALUE CBEER, ID IS CIOID,
FORMAT IS 5;
INSERT STRING ONWALL1, ID IS CIOID;
INSERT VALUE CBEER, ID IS CIOID,
FORMAT IS 5;
INSERT STRING BOTTLES, ID IS CIOID;
WRITE AFTER 1 NL, ID IS CIOID,
ABRANCH IS ERROR;
INSERT STRING TAKEDOWN, ID IS CIOID;
IF CBEER /= 1 THEN
INSERT VALUE (CBEER-1), ID IS CIOID,
FORMAT IS 5;
FI;
INSERT STRING ONWALL2, ID IS CIOID;
WRITE AFTER 1 NL, ID IS CIOID,
ABRANCH IS ERROR;
NO;
ERROR)
RELEASE DEVICE, ID IS CIOID,
ABRANCH IS EXIT;
EXIT)
EXIT;
END PROGRAM;
DATA;
END DATA;
*END;
ID BEERPROGRAM TYPE DOCUMENT;
CLA 19055;
NUM CAA 100 99;
REV A;
DAT 96-12-12;
DES ETO/TX/M/N STA;
RES ETO/TX/M/N STA;
APP ETO/TX/M/N TV;
END ID;
! The source parameter list !
DOCUMENT BEERSPARAM;
BLOCK
BEER;
TYPE
TYPEEXT
USE
NSYMB
NSYMB
BTBEER;
BTEXTBEER;
BEERPROGRAM;
BTBEER = #8000;
BTEXTBEER= #4000;
STRING BEERS = "BEERS";
NSYMB COCA99 = #0;
END BLOCK;
*END;
ID BEERSPARAM TYPE DOCUMENT;
CLA 19073;
NUM CAA 100 99;
REV A;
DAT 96-12-13;
DES ETO/TX/M/N STA;
RES ETO/TX/M/N STA;
APP ETO/TX/M/N TV;
END ID;
! Signal Survey !
DOCUMENT BEERSURVEY;
SIGNALSURVEY;
USE BLOCK BEER;
STTOR
STTORRY
,
,
R
S
,
,
723/15514 - APZ210
724/15514 - APZ210
END SIGNALSURVEY;
*END;
ID BEERSURVEY TYPE DOCUMENT;
CLA 15514;
NUM CAA 100 99;
REV A;
DAT 96-12-13;
DES ETO/TX/M/N STA;
RES ETO/TX/M/N STA;
APP ETO/ETOTX/M/N TV;
END ID;
OBJ
OBJ is an algebraic specification language.
*** OBJ version of 99 bottles of beer
*** programmer: Grigore Rosu grosu@cs.ucsd.edu
*** creator of OBJ language: Joseph Goguen
;
;
obj STRING is sort String .
ops We like some beer on the wall.
ops Take one bottle of wall down ,
ops And pass it arround the beer.
ops Does anybody want bottles more?
endo
:
:
:
:
-
String
String
String
String
.
.
.
.
obj LIST[X :: TRIV] is
sort List .
subsort Elt List [assoc] .
endo
make CHUG is LIST [ STRING + NAT ] endm
obj BEER is protecting CHUG .
subsort Nat List .
op bottle? : Nat - String .
var N : Nat .
eq beers(0) = Does anybody want some more? .
cq beers(N) = puke(N) beers(p N) if N 0 .
eq puke(N) = N bottle?(N) of beer on the wall , N bottle?(N) of beer.
Take one down , pass it arround , (p N) bottle?(p N) of beer on the
wall. .
cq bottle?(N) = bottle if N == 1 .
cq bottle?(N) = bottles if N =/= 1 .
endo
red beers(99) .
POV-Ray
POV-Ray is a ray-tracing program.
// povray 3 file for the 99 bottles of beer ...
#declare
#declare
#declare
#declare
#declare
S1
L1
L2
L3
L4
=
=
=
=
=
" bottles"
" of beer on the wall,\n"
" of beer.\n"
"Take one down and pass it around,\n"
" 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
}
Orthogonal
; 99 Bottles of Beer on the Wall
;
for Orthogonal
;
written by Brian Raiter 5/96
:set bX = 7
:set bY = 20
[0,0]
99 1
cw
~
0
~
0
@
~
1
@
cw
0
99
1
99
J
d
0
'l'
'l'
'a'
'w'
' '
ccw
cw
cw
?
!
c
0
cw
cw ' ' J
'o'
'r'
'n'
'e'
' '
'e'
't'
'b'
'h'
ccw
'e'
ccw
cw
0
0
':' 'd' 'n' 'u' 'o' 'r' ' ' 't' 'i'
':' 'e' 'r' 'o' 'm' ' ' 'e' 'm' cw
'o'
's'
?
c
0
s
'.' 0
ccw ?
s
' '
0
d
s
';' ' ' 0
cw
'y'
'u'
'b'
' '
','
' ' 'f' 'o' ' ' bY bX =
?
's' 'e'
'r'
'l' 'l' 'a' 'w' ' ' 'e' 'h' 't' cw 'o'
' ' cw
's'
's'
'a'
ccw 'p'
'b' ' '
'o' ','
't' 'n'
't' 'w'
'l' 'o'
ccw 'd'
' '
bY
~
0
~
1
@
'.'
0
c
0
cw
cw
' '
'o'
cw
s
's'
cw
cw
'f'
'G'
'e'
c
0
' '
'o'
'l'
0
s
'b'
' '
't'
ret
d
'e'
't'
't' 'o' cw
'b'
99 ' ' cw
'e' 'r' ' '
'o' ' ' 't'
' '
'n'
'o'
cw
'h'
't'
's'
' '
'e'
cw
bX
=
?
ccw cw
't'
'e'
#
'i'
'n'
cw
bX
bY
-
1
@
98
nop c
0
s
'T' 'a' 'k' 'e' ' ' H
'o'
cw
cw
PL/M-80
/*
* 99 bottles of beer in PL/M-80
*
* by John Durbetaki using AEDIT
*
*/
Ninety$Nine:
Do;
declare as
declare CRLF
LITERALLY
as
declare
declare
declare
declare
declare
declare
declare
declare
declare
BYTE DATA(99);
BYTE DATA(' of beer on the wall,',CRLF);
BYTE DATA(' of beeeeer . . . . ,',CRLF);
BYTE DATA('Take one down, pass it around,',CRLF);
BYTE DATA(' of beer on the wall.',CRLF);
BYTE DATA(CRLF,'Time to buy more beer!',CRLF);
BYTE;
BYTE;
BYTE;
Beers
Message1(*)
Message2(*)
Message3(*)
Message4(*)
End$Message(*)
STATUS
How$Many(128)
How$Many$Count
Copy: PROCEDURE(Ap,Bp,Count);
declare Ap
ADDRESS;
declare A BASED Ap
BYTE;
declare Bp
ADDRESS;
declare B BASED Bp
BYTE;
declare Count
BYTE;
DO WHILE Count 0;
B=A;
Ap=Ap+1;
Bp=Bp+1;
Count=Count-1;
END;
END;
'LITERALLY'
'0Dh,0Ah'
Make$How$Many: PROCEDURE(Beers);
declare Beers
BYTE;
if Beers = 0 THEN DO;
CALL Copy(.('No more bottles'),.How$Many(0),How$Many$Count=15);
END;
else if Beers = 1 THEN DO;
CALL Copy(.('One more bottle'),.How$Many(0),How$Many$Count=15);
END;
else DO;
if Beers 10 THEN DO;
How$Many(0)='0'+(Beers/10);
How$Many(1)='0'+(Beers MOD 10);
CALL Copy(.(' bottles'),.How$Many(2),8);
How$Many$Count=10;
END;
else DO;
How$Many(0)='0'+Beers;
CALL Copy(.(' bottles'),.How$Many(1),8);
How$Many$Count=9;
END;
END;
END;
Chug: PROCEDURE(Beers);
declare Beers
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
END;
BYTE;
Make$How$Many(Beers);
WRITE(0,.How$Many,Count,.STATUS);
WRITE(0,.Message1,SIZE(Message1),.STATUS);
WRITE(0,.How$Many,Count,.STATUS);
WRITE(0,.Message2,SIZE(Message2),.STATUS);
WRITE(0,.Message3,SIZE(Message3),.STATUS);
Make$How$Many(Beers-1);
WRITE(0,.How$Many,Count,.STATUS);
WRITE(0,.Message4,SIZE(Message4),.STATUS);
DO WHILE Beers 0;
CALL Chug(Beers);
Beers=Beers-1;
END;
CALL WRITE(0,.End$Message,SIZE(End$Message),.STATUS);
END;
NewtonScript
NewtonScript is an object-oriented language that runs on Apple Newton MessagePads. You
can get a Steve Weyer's free compiler for it at
http://www.netaxs.com/~weyer/newton/newtdev.htm.
// A simple NewtonScript program to 99 Bottles.
// Armen Nakashian, 3/13/97 armen@yawara.anime.net
BeerSong
{
Drink:func()
for b:=99 to 1 do
begin
print(bob(b) & " on the wall, " & bob(b) & ".");
print("Take one down, pass it around, " & bob(b-1) & " on the
wall.");
end,
bob:func(i):
if i==0 then return "no more bottles of beer",
else if i==1 then return "1 bottle of beer",
else return i & " bottles of beer",
}
Occam
-- compiled with the University of Kent "kroc" compiler
-- Tony Curtis 1997
-PROC beer (CHAN OF BYTE key, screen, error)
VAL INT BEERS IS 99 :
-- big fridge!
#USE "tty_utils.tco"
PROC sorp (VAL INT n, CHAN OF BYTE out)
-- singular or plural?
IF
n 1
out.string ("s", 1, out)
TRUE
SKIP
:
PROC sayit (VAL INT n, CHAN OF BYTE out)
-- text for each iteration
SEQ
out.number (n, 1, out)
out.string (" bottle", 1, out)
sorp (n, out)
out.string (" of beer on the wall, ", 1, out)
out.number (n, 1, out)
out.string (" bottle", 1, out)
sorp (n, out)
out.string (" of beer.", 1, out)
out.string ("*c*n", 1, out)
out.string ("Take one down, pass it around, ", 1, out)
VAL INT next IS n - 1 :
IF
next 0
SEQ
out.number (next, 1, out)
out.string (" bottle", 1, out)
sorp (next, out)
out.string (" of beer on the wall.", 1, out)
TRUE
out.string ("no bottles of beer on the wall.", 1, out)
out.string ("*c*n", 1, out)
:
PROC beers (VAL INT nbeers, CHAN OF BYTE out)
INT b :
SEQ
b := nbeers
WHILE b 0
SEQ
sayit (b, out)
b := b - 1
:
beers (BEERS, screen)
:
PL/SQL
PL/SQL is a programming language that resides in an Oracle database. As PL/SQL has no
standard input or output this version is written to be run from the SQLPlus command line
using an anonymous PL/SQL block.
/* Start of code */
set serveroutput on
DECLARE
counter
NUMBER;
BEGIN
dbms_output.enable;
FOR counter IN REVERSE 1..99 LOOP
dbms_output.put_line(counter || ' bottles of beer on the
wall,');
dbms_output.put_line(counter || ' bottles of beer.');
dbms_output.put_line('Take one down, pass it around,');
IF (counter != 1) THEN
dbms_output.put_line(counter - 1 || ' bottles of
beer on the wall.');
ELSE
dbms_output.put_line('No more beers.');
END IF;
END LOOP;
END;
/
/* End of code (The "/" in the line above is very important) */
PH/FI
PH/FI is a light, and powerful, interpreter for server-parsed ("dynamic" this year, SSH since
NCSA invented the thing ages ago) html which can be used either as a CGI redirected
processor or embbedded in Apache servers. Its web site is http://php.iquest.net/.
<HTML>
<HEAD>
<TITLE>
99 Bottles of beer.
</TITLE>
<META NAME="Author" CONTENT="Alejandro López-Valencia">
<META NAME="E-Mail" CONTENT="palopez@usa.net">
<META NAME="Description" CONTENT="Written in PHP/FI 2.0">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?
/* Don't show the access information footer */
setshowinfo(0)
>
<?
/* Drink with the boys... */
$hic = 99;
while ($hic > 0) (
$huc = $hic - 1;
/* Waste CPU, but you are using a Cray, aren't you? */
if ($hic = 1) (
$huc = $hic;
) ;
if ($hic = 1) $bottles = "bottle" else $bottles = "bottles" ;
echo $hic $bottles of beer on the wall, $hic $bottles of beer. <BR> ;
echo Take one and pass it around, <BR> ;
echo "$huc $bottles of beer on the wall. <BR>" ;
$hic--;
)
/* Pass
echo No
echo No
echo Go
echo 99
>
out */
more bottles of beer on the wall. <BR> ;
more bottles of beer... <BR> ;
to the store and buy some more... <BR> ;
bottles of beer. <BR> ;
</BODY>
</HTML>
OCL
Operation Control Language is the JCL/batch/scripting language for the IBM System
32/34/36 computer series..
**
//
//
//
//
//
//
//
//
//
//
//
//
//
99 Bottles of Beer on the Wall
EVALUATE P1=99 P2='s'
TAG MOREBEER
* '?1? bottle?2? of beer on the wall,'
* '?1? bottle?2? of beer,'
IFF '?1?'='No more' * 'Take one down and pass it around,'
ELSE * 'Go to the store and get some more,'
IFF '?1?'='No more' EVALUATE P1=?1?-1 * decrement the counter
ELSE EVALUATE P1=99 * reseed counter
IF ?1?1 EVALUATE * leave P2='s' (for efficiency - OCL is interpreted)
ELSE IF ?1?=1 EVALUATE P2=''
ELSE IF ?1?=0 EVALUATE P1='No more' P2='s'
* '?1? bottle?2? of beer on the wall.'
GOTO MOREBEER * ad infinitum
RC
rc shell script language..
#!/usr/local/bin/rc
# rc shell version of 99 bottles of beer
# by Tom Culliton (culliton@clark.net)
count = (99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84
77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62
55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18
11 10 9 8 7 6 5 4 3 2 1)
bottles = bottles; one = one
for (i in $count) {
if (~ $i 1) {bottles = bottle; one = it}
if (! ~ $i 99) {
echo $i $bottles 'of beer on the wall.'
echo
}
echo $i $bottles 'of beer on the wall,'
echo $i $bottles 'of beer,'
echo 'take' $one 'down and pass it around,'
}
echo 'no more bottles of beer on the wall!'
83
61
39
17
82
60
38
16
81
59
37
15
80
58
36
14
79
57
35
13
78
56
34
12
RAMIS Executive
*----------------------------------------------------------------------* 99 BOTTLES OF BEER ON THE WALL - RAMIS EXECUTIVE VERSION
*----------------------------------------------------------------------CATALOGS BEER
&&COUNT/I2 = 99;
&&LOOP
&&BOTTLES/A7 = IF &COUNT GT 1 THEN 'BOTTLES' ELSE 'BOTTLE ';
&&PRINT &COUNT &BOTTLES OF BEER ON THE WALL, &COUNT &BOTTLES OF BEER
&&PRINT TAKE ONE DOWN, PASS IT AROUND
&&COUNT/I2 = &COUNT - 1;
&&IF &COUNT GT 0 GOTO LOOP;
&&PRINT NO MORE BOTTLES OF BEER ON THE WALL, NO MORE BOTTLES OF BEER
&&PRINT GO TO THE STORE AND BUY SOME MORE
END CATALOGS
EXEC BEER
RAMIS SBX
*---------------------------------------------------------------------* 99 BOTTLES OF BEER ON THE WALL - RAMIS SBX VERSION
*---------------------------------------------------------------------PROCESS;
DECLARE COUNT AS I2;
DO FROM COUNT = 99 TO 2 BY -1;
PRINT &COUNT BOTTLES OF BEER ON THE WALL, &COUNT BOTTLES OF BEER;
PRINT TAKE ONE DOWN, PASS IT AROUND;
ENDDO;
PRINT 1 BOTTLE OF BEER ON THE WALL, 1 BOTTLE OF BEER;
PRINT TAKE ONE DOWN, PASS IT AROUND;
PRINT NO MORE BOTTLES OF BEER ON THE WALL, NO MORE BOTTLES OF BEER;
Compilation Copyright 1995, 1996, 1997 Tim Robinson. All Rights Reserved
Permission to copy enthusiastically granted to instructors of computer science
(who would like to demonstrate the styles of different programming languages
to their students) provided that the names of the contributors are retained.
More beer
Back to the Funhouse
SNOBOL
* 99 BOTTLES OF BEER IN SNOBOL (UNTESTED)
BEER = 99
MOREBEER OUTPUT = BEER ' BOTTLES OF BEER ON THE WALL'
OUTPUT = BEER ' BOTTLES OF BEER'
OUTPUT = 'TAKE ONE DOWN, PASS IT AROUND'
BEER = BEER - 1
OUTPUT = BEER ' BOTTLES OF BEER ON THE WALL'
GT(BEER,0)
: S(MOREBEER)
OUTPUT = 'NO MORE BOTTLES OF BEER ON THE WALL'
OUTPUT = 'NO MORE BOTTLES OF BEER'
OUTPUT = 'GO TO THE STORE AND BUY SOME MORE'
OUTPUT = '99 BOTTLES OF BEER'
END
Smalltalk
"Programmer: patrick m. ryan - pryan@access.digex.net
"http://www.access.digex.net/~pryan
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.
]
Vax DCL
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
I=100
FIRSTLOOP:
IF (I.EQ. 1) THEN GOTO LAST_BOTTLE
WRITE SYS$OUTPUT I," BOTTLES OF BEER ON THE WALL"
WRITE SYS$OUTPUT I," BOTTLES OF BEER"
WRITE SYS$OUTPUT "IF ONE OF THEM SHOULD HAPPEN TO FALL"
WRITE SYS$OUTPUT I-1," BOTTLE OF BEER ON THE WALL"
WRITE SYS$OUTPUT " "
I=I-1
GOTO FIRSTLOOP
LAST_BOTTLE:
WRITE SYS$OUTPUT "1 BOTTLE OF BEER ON THE WALL"
WRITE SYS$OUTPUT "1 BOTTLE OF BEER"
WRITE SYS$OUTPUT "IF IT SHOULD HAPPEN TO FALL"
WRITE SYS$OUTPUT "NO MORE BOTTLES OF BEER ON THE WALL"
--- A noteworthy alternative
;
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
VMS DCL version of 99 Bottles of Beer
I=100
FIRSTLOOP:
C=0
L=1
PAUSE:
C=C+1
IF (I.EQ. 1) THEN GOTO LAST_BOTTLE
IF (C .EQ. 1500) THEN GOTO FIRSTCLEAN
GOTO PAUSE
FIRSTCLEAN:
GOTO WIPESCN
FIRSTLINE:
WRITE SYS$OUTPUT I," bottles of beer on the wall,"
C=0
L=2
FIRSTPAUSE:
C=C+1
IF (C .EQ. 2000) THEN GOTO SECONDCLEAN
GOTO FIRSTPAUSE
SECONDCLEAN:
GOTO WIPESCN
SECONDLINE:
WRITE SYS$OUTPUT I," bottles of beer."
C=0
L=3
SECONDPAUSE:
C=C+1
IF (C .EQ. 1500) THEN GOTO THIRDCLEAN
GOTO SECONDPAUSE
THIRDCLEAN:
GOTO WIPESCN
THIRDLINE:
WRITE SYS$OUTPUT "If one of them should happen to fall...."
C=0
L=4
THIRDPAUSE:
C=C+1
IF (C .EQ. 1500) THEN GOTO FOURTHCLEAN
GOTO THIRDPAUSE
FOURTHCLEAN:
GOTO WIPESCN
FOURTHLINE:
WRITE SYS$OUTPUT I-1," bottles of beer on the wall."
I=I-1
GOTO FIRSTLOOP
LAST_BOTTLE:
C=0
L=5
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
FOURTHPAUSE:
C=C+1
IF (C .EQ. 1500) THEN GOTO FITHCLEAN
GOTO FOURTHPAUSE
FITHCLEAN:
GOTO WIPESCN
FITHLINE:
WRITE SYS$OUTPUT "1 bottle of beer on the wall,"
C=0
L=6
FITHPAUSE:
C=C+1
IF (C .EQ. 1200) THEN GOTO SIXTHCLEAN
GOTO FITHPAUSE
SIXTHCLEAN:
GOTO WIPESCN
SIXTHLINE:
WRITE SYS$OUTPUT "1 bottle of beer..."
C=0
L=7
SIXTHPAUSE:
C=C+1
IF (C .EQ. 2200) THEN GOTO SEVENTHCLEAN
GOTO SIXTHPAUSE
SEVENTHCLEAN:
GOTO WIPESCN
SEVENTHLINE:
WRITE SYS$OUTPUT "If it should happen to fall...."
C=0
L=8
LASTPAUSE:
C=C+1
IF (C .EQ. 2000) THEN GOTO LASTCLEAN
GOTO LASTPAUSE
LASTCLEAN:
GOTO WIPESCN
LASTLINE:
WRITE SYS$OUTPUT "No more bottles of beer on the wall."
GOTO QUIT
WIPESCN:
C=0
WIPE:
C=C+1
WRITE SYS$OUTPUT " "
IF (C .EQ. 25) THEN GOTO SONGLINE
GOTO WIPE
SONGLINE:
IF (L .EQ. 1) THEN GOTO FIRSTLINE
IF (L .EQ. 2) THEN GOTO SECONDLINE
IF (L .EQ. 3) THEN GOTO THIRDLINE
IF (L .EQ. 4) THEN GOTO FOURTHLINE
IF (L .EQ. 5) THEN GOTO FITHLINE
IF (L .EQ. 6) THEN GOTO SIXTHLINE
IF (L .EQ. 7) THEN GOTO SEVENTHLINE
$ IF (L .EQ. 8) THEN GOTO LASTLINE
$ QUIT:
SAS
/* SAS version of 99 bottles of beer
*/
/* by Whitey (whitey@netcom.com) - 06/05/95 */
data _null_;
do i = 99 to 1 by -1;
put i 'bottles of beer on the wall,' i 'bottles of beer,';
put 'take one down, pass it around,';
j = i - 1;
if j = 0 then
put 'no more ' @;
else
put j @;
put 'bottles of beer on the wall.';
end;
run;
TeX/LaTeX
%% TeX/LaTeX version of 99 bottles of Beer
%%
%% Craig J Copi - copi@oddjob.uchicago.edu
%%
\parindent=0pt
\newcount\beercurr
\def\beer#1{\beercurr=#1\let\next=\removebeer\removebeer}
\def\removebeer{
\ifnum\beercurr1
\the\beercurr\ bottles of beer on the wall,\par
\the\beercurr\ bottles of beer,\par
take one down, pass it around,\par
\advance\beercurr by -1
\the\beercurr\ bottle\ifnum1