Upload
metas4life
View
25
Download
3
Tags:
Embed Size (px)
DESCRIPTION
java, 99 beers
Citation preview
99 Bottles of Beer on the Wall
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 REM Basic version of 99 bottles of beer
20 FOR X=100 TO 1 STEP -1
30 PRINT X;"Bottle(s) of beer on the wall,";X;"bottle(s) of beer"
40 PRINT "Take one down and pass it around,"
50 PRINT X-1;"bottle(s) of beer on the wall"
60 NEXT
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 [email protected] 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 GuideBeerMasters Tasting SocietyYahoo 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 [email protected]
#include
int main()
{
int bottles = 99;
while ( bottles > 0 )
{
cout
0 then
str = n
else
str = "No "
end if
str = str & " bottle"
if n 1 then str = str & "s"
str = str & " of beer on the wall!
"
Response.Write str
Response.Write "
"
loop while n > 0
Response.Write "Buy more
beer!"
%>
C/C++ Preprocessor
This is the pre-processor for C or C++. Normally, not a language in itself, but created to make using C/C++ easier. This is a novel use of the pre-processor
-- BEER.CPP ---------------------------------------------------------
// 99 Bottles written entirely in Visual C++ preprocessor directives.
// By Wim Rijnders.
#pragma warning(disable : 4005 )
#define BOTTLES "bottles"
#define TAKE_ONE_DOWN "Take one down, pass it around,"
#define DEC_NUM 9
#define DEC_STR "9"
#define DEC2_NUM 9
#define DEC2_STR "9"
#define TEST_BOTTLES(a,b) (DEC2_NUM == a && DEC_NUM == b )
#define STILL_HAVE__BOTTLES !TEST_BOTTLES(0,0)
#define NO_MORE__BOTTLES TEST_BOTTLES(0,0)
#define JUST_ONE__BOTTLE TEST_BOTTLES(0,1)
#define OF_BEER DEC2_STR DEC_STR " " BOTTLES " of beer"
#define BEER_ON_WALL OF_BEER " on the wall"
#include "sing.h"
-- SING.H -----------------------------------------------------------
//Following to beat the 32-file include limit of VC
#if STILL_HAVE__BOTTLES
#include "stanza.h"
#include "stanza.h"
#include "stanza.h"
#include "stanza.h"
#include "sing.h"
#endif
-- STANZA.H ---------------------------------------------------------
#if STILL_HAVE__BOTTLES
#pragma message(BEER_ON_WALL ",")
#pragma message(OF_BEER ",")
#pragma message(TAKE_ONE_DOWN)
#include "dec.h"
#if NO_MORE__BOTTLES
#define DEC2_STR ""
#define DEC_STR "No more"
#endif
#if JUST_ONE__BOTTLE
#define BOTTLES "bottle"
#else
#define BOTTLES "bottles"
#endif
#pragma message(BEER_ON_WALL ".")
#pragma message("")
#endif
-- DEC.H ------------------------------------------------------------
#if DEC_NUM == 9
#define DEC_NUM 8
#define DEC_STR "8"
#elif DEC_NUM == 8
#define DEC_NUM 7
#define DEC_STR "7"
#elif DEC_NUM == 7
#define DEC_NUM 6
#define DEC_STR "6"
#elif DEC_NUM == 6
#define DEC_NUM 5
#define DEC_STR "5"
#elif DEC_NUM == 5
#define DEC_NUM 4
#define DEC_STR "4"
#elif DEC_NUM == 4
#define DEC_NUM 3
#define DEC_STR "3"
#elif DEC_NUM == 3
#define DEC_NUM 2
#define DEC_STR "2"
#elif DEC_NUM == 2
#define DEC_NUM 1
#define DEC_STR "1"
#elif DEC_NUM == 1
#define DEC_NUM 0
#define DEC_STR "0"
#elif DEC_NUM == 0
#include "dec2.h"
#define DEC_NUM 9
#define DEC_STR "9"
#endif
-- DEC2.H -----------------------------------------------------------
#if DEC2_NUM == 9
#define DEC2_NUM 8
#define DEC2_STR "8"
#elif DEC2_NUM == 8
#define DEC2_NUM 7
#define DEC2_STR "7"
#elif DEC2_NUM == 7
#define DEC2_NUM 6
#define DEC2_STR "6"
#elif DEC2_NUM == 6
#define DEC2_NUM 5
#define DEC2_STR "5"
#elif DEC2_NUM == 5
#define DEC2_NUM 4
#define DEC2_STR "4"
#elif DEC2_NUM == 4
#define DEC2_NUM 3
#define DEC2_STR "3"
#elif DEC2_NUM == 3
#define DEC2_NUM 2
#define DEC2_STR "2"
#elif DEC2_NUM == 2
#define DEC2_NUM 1
#define DEC2_STR "1"
#elif DEC2_NUM == 1
#define DEC2_NUM 0
#define DEC2_STR ""
#endif
Brainf***
Yes, it's a dirty word. An explanation and an interpreter of this can be found at http://www.cats-eye.com/cet/soft/lang. +++++++++[-][-][-]
Bottles of Beer
#idx# Bottles of Beer on the wall, #idx# Bottles of Beer,
Take one down, pass it around, #Evaluate("#idx# - 1")# 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
ADL
ADL is Adventure Definition Language
{ This version of beer.adl is the normal procedural one which has }
{ no user interaction, and only prints out the song. Quite boring, }
{ really. Ross Cunniff, 1997 [email protected] }
START =
LOCAL i, s;
($setg i 99)
(WHILE ($gt @i 0) DO
(IF ($gt @i 1) THEN
($say ($str @i) " bottles of beer on the wall.\n")
($say ($str @i) " bottles of beer.\n")
ELSE
($say "1 bottle of beer on the wall.\n")
($say "1 bottle of beer.\n")
)
($say "You take one down, pass it around.\n")
($setg i ($minus @i 1))
(IF ($gt @i 1) THEN
($say ($str @i) " bottles of beer on the wall.\n\n")
ELSEIF ($eq @i 1) THEN
($say "1 bottle of beer on the wall.\n\n")
ELSE
($say "No more bottles of beer on the wall.\n")
)
)
($spec 3)
;
CLOS
Common Lisp Object System
;;;; 99 bottles of beer as a CLOS program.
;;;; Author: Christopher Oliver ([email protected])
;;;; Aug 10, 1997
(defconstant *bottles-at-store* 500)
(defconstant *bottles-at-gathering* 99)
(defclass bottle-of-beer () ())
(defclass beer-holder () ((inventory :accessor inventory :initform nil)))
(defclass wall (beer-holder) ((on-hand :accessor on-hand :initform 0)))
(defclass store (beer-holder) ())
(defmethod consume ((bottle bottle-of-beer))
(format t "pass it around.~%"))
(defmethod add-to-inventory ((holder beer-holder) (bottle bottle-of-beer))
(push bottle (inventory holder)))
(defmethod remove-from-inventory ((holder beer-holder))
(pop (inventory holder)))
(defmethod add-to-inventory :after ((wall wall) (bottle bottle-of-beer))
(incf (on-hand wall)))
(defmethod remove-from-inventory ((wall wall))
(let ((bottle (call-next-method)))
(when bottle
(format t "~&Take ~:[one~;it~] down, and " (= (on-hand wall) 1))
(decf (on-hand wall)))
bottle))
(defmethod count-bottles ((wall wall) &key (long-phrase nil))
(let ((on-hand (on-hand wall)))
(format t "~&~:[~@(~R~)~;No more~*~] bottle~p of beer~@[ on the wall~]."
(zerop on-hand) on-hand on-hand long-phrase)))
(defmethod remove-from-inventory ((store store))
(let ((bottle (call-next-method)))
(if bottle
(unless (consp (inventory store))
(format t "~&(You've exhausted my supply!)~%"))
(format t "~&(I have nothing left to sell you!)~%"))
bottle))
(defmethod replenish ((wall wall) (store store))
(format t "~&Go to the store, and buy some more.")
(dotimes (number-bought 99)
(let ((bottle (remove-from-inventory store)))
(cond (bottle (add-to-inventory wall bottle))
((plusp number-bought) (return-from replenish))
(t (error "The end is at hand!"))))))
(defun ninety-nine ()
(let ((store (make-instance 'store))
(wall (make-instance 'wall)))
(dotimes (ix *bottles-at-store*)
(add-to-inventory store (make-instance 'bottle-of-beer)))
(dotimes (ix *bottles-at-gathering*)
(add-to-inventory wall (make-instance 'bottle-of-beer)))
(loop
(progn
(count-bottles wall :long-phrase t)
(count-bottles wall)
(let ((this-bottle (remove-from-inventory wall)))
(if this-bottle
(consume this-bottle)
(replenish wall store)))
(count-bottles wall :long-phrase t)
(format t "~&~%")))))
CorVu
CorVu is an integrated business intelligence suite
bottles = 99;
(bottles 0)
?*
(
text = ((bottles 1) ? " bottles" : " bottle");
display(bottles, text, " of beer on the wall,");
newline();
display(bottles, text, " of beer,");
newline();
display("Take one down, and pass it around,");
newline();
bottles = bottles - 1;
(bottles 0)
?
(
text = ((bottles 1) ? " bottles" : " bottle");
display(bottles, text, " of beer on the wall.")
)
:
(
display("No more bottles of beer on the wall.")
);
newline(2)
);
display("No more bottles of beer on the wall,");
newline();
display("No more bottles of beer,");
newline();
display("Go to the store and buy some more,");
newline();
display("99 bottles of beer on the wall.");
newline()
Amanda
Amanda is a DOS version of Miranda. I'm told it's freeware, but was given no reference.
/*
I made some changes to the miranda script by Tim Walls.
Changes by Gavin Spearhead ([email protected])
*/
bottlesofbeer :: num - [char]
bottlesofbeer n = "\nNo more bottles of beer on the wall, \n"
++ "no more bottles of beer.\n" , if n = 0
= "\nOne 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" ++ itoa(n) ++ " bottles of beer on the wall, "
++ itoa(n)
++ " bottles of beer,\nTake one down and pass it around"
++ (bottlesofbeer (n-1)) , otherwise
Boxer Macro Language
Boxer is an editor for DOS/OS2 environment. See www.boxersoftware.com/users/dhamel * 99 bottles of beer on the wall
* In the Boxer macro language
* Load / Compile this macro
* And execute by pressing :
* CTRL-A
* ALT-Y
* 98
* CTRL-B
*
* Written by Gavin Spearhead 1997
99bottlesofbeeronwall99bottlesofbeer
Takeonedown,passitaround98bottles
ofbeeronwall
11
1
CAL
Cakewalk Application Language (v3). Cakewalk is a MIDI sequencing program which can manipulate midi data using CAL programs. This program is multi-file and file name breaks are in italics.
-- BEER.CAL --
; BEER.CAL by Tom Murphy 7 for Cakewalk CAL
; (version 3)
; It will even play the song along if you have a MIDI device
; hooked up, otherwise it is REALLY boring.
; + "!%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 ([email protected]).
{ False version of 99 Bottles by Marcus Comstedt ([email protected]) }
[$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 [email protected]
dec app :( list ( char ) X list ( char )) - list ( char ) ;
dec i2c : num - char;
dec i2s : num - list(char);
dec beer : num - list(char);
--- app ( nil , w )
EXEC
* EXEC version of 99 Bottles of beer program
* By Torbjrn Vaaje ([email protected])
*
&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 ([email protected])
' 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 = "([email protected])"
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...)
' 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 ([email protected])
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 ([email protected])
*/
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
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 [email protected] *
* 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 ([email protected])";
"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 RCDUMMYFD S U S T R
BEER RFSUBFILE SM4SUBF1
BEER ERDATE
BEER AA
BEER AA Michael Passer
BEER AA
BEER AA This program requires one dummy record of input
BEER AA (the M4OLD DD) to trigger execution. Output is
BEER AA sent to the first subfile (M4SUBF1 DD).
BEER AA
BEER TFBOTTLESZ 3Z 100
BEER AA ----+----1----+-
BEER TFBOB 15C BOTTLES OF BEER
BEER TFOTW 11C ON THE WALL
BEER TFTOD 13C TAKE ONE DOWN
BEER TFPIA 14C PASS IT AROUND
BEER TFCOMMA 1C ,
BEER TFPERIOD 1C .
BEER TFBLANK 1C
BEER PR GO SUB SING
SING ERDATE S 100
SING PR TBOTTLESZEQD0
SING PR GS RETURN
SING PR GO SUB CHORUS
SING PR R TMINUS1Z TBOTTLESZ
SING PR GO REQUEST SING
CHORUS ERDATE S
CHORUS TFMINUS1Z 3Z
CHORUS TFBOTTLES 3C
CHORUS TFMINUS1 2C
CHORUS PR TBOTTLESZ- D1 TMINUS1Z
CHORUS PR R TBOTTLESZ TBOTTLES
CHORUS PR R TMINUS1Z TMINUS1
CHORUS E1 NR SUBFILE V
CHORUS R1 TBOTTLES
CHORUS R1 TBLANK
CHORUS R1 TBOB
CHORUS R1 TBLANK
CHORUS R1 TOTW
CHORUS R1 TCOMMA
CHORUS E2 NR SUBFILE V
CHORUS R2 TBOTTLES
CHORUS R2 TBLANK
CHORUS R2 TBOB
CHORUS R2 TCOMMA
CHORUS E3 NR SUBFILE V
CHORUS R3 TTOD
CHORUS R3 TCOMMA
CHORUS R3 TBLANK
CHORUS R3 TPIA
CHORUS R3 TCOMMA
CHORUS E4 NR SUBFILE V
CHORUS R4 TMINUS1
CHORUS R4 TBLANK
CHORUS R4 TBOB
CHORUS R4 TBLANK
CHORUS R4 TOTW
CHORUS R4 TPERIOD
CHORUS E5 NR SUBFILE V
CHORUS R5 TBLANK
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
; [email protected] (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 - [email protected]
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 ([email protected]) }
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 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 NUM_BOT FIXED DEC(3);
DCL PHRASE1 CHAR(100) VAR;
DCL PHRASE2 CHAR(100) VAR;
DCL PHRASE3 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 30
C X DOWGE0
C EXCPT
C SUB 1 X
C END
C SETON LR
OSCREEN E
O X 3
O 26 'BOTTLES OF BEER ON THE'
O 31 'WALL,'
O X 36
O 53 'BOTTLES OF BEER'
O E
O 22 'TAKE ONE DOWN AND PASS'
O 32 'IT AROUND'
Python
#!/usr/local/bin/python
# python version of 99 bottles of beer, compact edition
# by Fredrik Lundh ([email protected])
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
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
.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 ([email protected]) *)
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 [email protected]
* 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,
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 ([email protected])
;
; 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 'NO MORE BOTTLES OF BEER ON THE WALL'
WRITE 'NO MORE BOTTLES OF BEER'
WRITE 'GO TO THE STORE AND BUY SOME MORE'
WRITE '99 BOTTLES OF BEER'
END
WRITE '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, [email protected];
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 * A portable version for those who need this vital application *
REM * with them at all times. The following is written in Psion OPL, *
REM * the language used in the popular Series 3 and Series 3a palmtops *
REM * (and other previous Psion products). *
REM * *
REM * by Dave Wilson, [email protected] *
REM * *
REM ********************************************************************
PROC Main:
LOCAL bottles%
LOCAL bottle$(10)
CLS
bottles%=99
bottle$=" bottles"
PRINT "99 Bottles of Beer"
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
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 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 - [email protected]
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!"
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 ([email protected]) */
/* 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, /* File pointer: where to write the song */
ctx_bottle, /* " bottle" */
ctx_bottle_of_beer, /* " bottle of beer" */
ctx_bottles_of_beer, /* " bottles of beer" */
ctx_on_the_wall; /* " on the wall" */
}
#define DEFAULT_FNAME "beer.txt"
"XXXXBEERPGM\00\0C"(var fname)
{
var i;
var of_beer;
var sentence;
if (open_one_context(Q_CTX_NAME) 1) {
/* Error opening context */
return (-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 [email protected] !
! 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 BTBEER;
TYPEEXT BTEXTBEER;
USE BEERPROGRAM;
NSYMB BTBEER = #8000;
NSYMB 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 , R , 723/15514 - APZ210 ;
STTORRY , S , 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 [email protected]
*** creator of OBJ language: Joseph Goguen
obj STRING is sort String .
ops We like some beer on the wall. : - String .
ops Take one bottle of wall down , : - String .
ops And pass it arround the beer. : - String .
ops Does anybody want bottles more? : - String .
endo
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 S1 = " bottles"
#declare L1 = " of beer on the wall,\n"
#declare L2 = " of beer.\n"
#declare L3 = "Take one down and pass it around,\n"
#declare L4 = " of beer on the wall.\n\n"
#declare Beer = 99
#declare S2 = concat(str(Beer,0,0),S1)
#render "\n"
#while (Beer 0)
#render concat(S2,L1)
#render concat(S2,L2)
#render L3
#declare Beer = Beer - 1
#if (Beer = 1)
#declare S2 = "1 bottle"
#else
#if (Beer = 0)
#declare S2 = "No more bottles"
#else
#declare S2 = concat(str(Beer,0,0),S1)
#end
#end
#render concat(S2,L4)
#end
sphere { 0, 1 pigment { colour rgb } }
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 cw 0 ':' 'd' 'n' 'u' 'o' 'r' ' ' 't' 'i' ' ' cw
99 cw 0 ':' 'e' 'r' 'o' 'm' ' ' 'e' 'm' cw 's'
1 ? 'o' 's'
99 ! 's' 'a'
cw J c 0 cw ? c 0 s '.' 0 ccw ? s ' ' ccw 'p'
~ d cw ' ' J 0 d s ';' ' ' 0 cw 'y' 'b' ' '
0 0 'o' 'r' 'u' 'o' ','
~ 'l' 'n' 'e' 'b' 't' 'n'
0 'l' ' ' 'e' ' ' 't' 'w'
@ 'a' 't' 'b' ',' 'l' 'o'
~ 'w' 'h' ccw ' ' 'f' 'o' ' ' bY bX = ? 's' 'e' ccw 'd'
1 ' ' 'e' 'r' ' '
@ ccw ccw cw 'l' 'l' 'a' 'w' ' ' 'e' 'h' 't' cw 'o' bY
~ '.' cw 's' 'e' 'l' 't' 't' 'o' cw ' ' 't' bX
0 0 ' ' cw c 0 ret 'b' 'n' 's' =
~ c 'o' cw 0 s d 99 ' ' cw 'o' ' ' ?
1 0 cw 'f' ' ' 'b' 'e' 'e' 'r' ' ' cw 'e' ccw cw
@ cw s 'G' 'o' ' ' 't' 'o' ' ' 't' 'h' 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 LITERALLY 'LITERALLY'
declare CRLF as '0Dh,0Ah'
declare Beers BYTE DATA(99);
declare Message1(*) BYTE DATA(' of beer on the wall,',CRLF);
declare Message2(*) BYTE DATA(' of beeeeer . . . . ,',CRLF);
declare Message3(*) BYTE DATA('Take one down, pass it around,',CRLF);
declare Message4(*) BYTE DATA(' of beer on the wall.',CRLF);
declare End$Message(*) BYTE DATA(CRLF,'Time to buy more beer!',CRLF);
declare STATUS BYTE;
declare How$Many(128) BYTE;
declare How$Many$Count BYTE;
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;
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 BYTE;
CALL Make$How$Many(Beers);
CALL WRITE(0,.How$Many,Count,.STATUS);
CALL WRITE(0,.Message1,SIZE(Message1),.STATUS);
CALL WRITE(0,.How$Many,Count,.STATUS);
CALL WRITE(0,.Message2,SIZE(Message2),.STATUS);
CALL WRITE(0,.Message3,SIZE(Message3),.STATUS);
CALL Make$How$Many(Beers-1);
CALL WRITE(0,.How$Many,Count,.STATUS);
CALL WRITE(0,.Message4,SIZE(Message4),.STATUS);
END;
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 [email protected]
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/.
99 Bottles of beer.