// C++ version of 99 Bottles of beer // programmer: Tim Robinson<EMAIL_ADDRESS>#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<EMAIL_ADDRESS>#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<EMAIL_ADDRESS>#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; }
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 PIC 9. 88 END-OF-FILE VALUE 1. 05 COUNTERS. 10 BOTTLES PIC 999 VALUE 0. 01 RECORD-OUT. 05 LINE1. 10 NUMBER-OF-BEERS-1 PIC ZZ9. 10 PIC X(28) VALUE "BOTTLES OF BEER IN THE WALL ". 10 PIC X VALUE ",". 10 NUMBER-OF-BEERS-2 PIC ZZ9. 10 PIC X. 10 PIC X(17) VALUE "BOTTLES OF BEER.". 05 LINE2. 10 PIC X(34) VALUE "TAKE ONE DOWN AND PASS IT ARROUND ". 10 NUMBER-OF-BEERS-3 PIC ZZ9. 10 PIC X. 10 PIC X(28) VALUE "BOTTLES OF BEER IN THE WALL". * PROCEDURE DIVISION. DRIVER-MODULE. PERFORM INITIALIZATION. PERFORM PROCESS UNTIL END-OF-FILE. PERFORM TERMINATION. STOP RUN. * INITIALIZATION. OPEN OUTPUT OUTPUT-FILE. ADD 100 TO BOTTLES. * PROCESS. IF BOTTLES = 0 THEN COMPUTE E-O-F = 1 ELSE PERFORM WRITE-ROUTINE END-IF. * TERMINATION. CLOSE OUTPUT-FILE. * WRITE-ROUTINE. MOVE BOTTLES TO NUMBER-OF-BEERS-1, NUMBER-OF-BEERS-2. COMPUTE BOTTLES = BOTTLES - 1. WRITE BEERS-OUT FROM LINE1. MOVE BOTTLES TO NUMBER-OF-BEERS-3. WRITE BEERS-OUT FROM LINE2.
/* * 99 bottles of beer in ansi c * * by Bill Wein<EMAIL_ADDRESS>* */ #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 beer on the wall,\n", beers, s); printf("%d bottle%s of beeeeer . . . ,\n", beers, s); printf("Take one down, 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 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<EMAIL_ADDRESS>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;
#!/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<EMAIL_ADDRESS># 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
#!/usr/bin/awk -f # awk version of 99 bottles of beer # by Whitey<EMAIL_ADDRESS>- 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" : "") }
#!/bin/sh # Bourne shell version of 99 Bottles # Craig J Copi -<EMAIL_ADDRESS># 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 . . . ."
;; Bottles by Rebecca Walpole<EMAIL_ADDRESS>;; 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 (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 \%number% %noun1% of beer on the wall, &type %number% %noun1% of beer, &type Take one down, pass it around, &type [calc %number% - 1] %noun2% of beer on the wall &end &return
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) #)
/* 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
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.
# 99 Bottles of Beer # # by Otto Stolz<EMAIL_ADDRESS># ( PROC width = (INT x) INT: (x>9 | 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 )
-- AppleScript version of "99 Bottles of Beer" -- by Kristopher Johnson<EMAIL_ADDRESS>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
// BCPL version of 99 Bottles of Beer. // hacked by Akira KIDA<EMAIL_ADDRESS>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 $)
//language Concurrent Clean - lazy pure functional // Author: Jan Krynicky<EMAIL_ADDRESS>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 Light version of 99 bottles of beer *) (* Written by Bow-Yaw Wang<EMAIL_ADDRESS>*) 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;;
% 99 bottles of beer in CLU by<EMAIL_ADDRESS>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
;Written by Bill Ensinger<EMAIL_ADDRESS>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 <- (beer (ninetynine ?bottlenum)) (test (> ?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 <- (beer (ninetynine ?bottlenum)) => (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 <- (beer (ninetynine ?bottlenum)) => (printout t ?bottlenum " bottle of beer on the wall," t) (printout t ?bottlenum " bottle of beer." t) (printout t "Take one down, pass it around," t) (printout t "No more bottles of beer on the wall!" t) )
.key num_bottles set countset 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
0010 // bottles of beer 0020 0030 FOR x# := 99 TO 1 STEP -1 DO 0040 bottles(x#, TRUE) 0050 bottles(x#, FALSE) 0060 PRINT "Take one down, pass it around."  0280 ENDPROC bottles
#!/bin/bash # Bourne Again shell version of 99 Bottles # Dave Plonka -<EMAIL_ADDRESS>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
#!/usr/bin/bs # bs version of 99 Bottles # Dave Plonka -<EMAIL_ADDRESS># 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
PGM /* 99 Bottles of Beer in AS/400 CL (Command Language) */ /* Programmer: Werner Grzemba<EMAIL_ADDRESS>*/ /* To avoid the necessity of any user action, the output is */ /* sent to the status line (except of the buy-request at end) */ DCL VAR(&MSG) TYPE(*CHAR) LEN(79) DCL VAR(&BEER1) TYPE(*CHAR) LEN(30) VALUE(' + bottles of beer on the wall, ') DCL VAR(&BEER2) TYPE(*CHAR) LEN(31) VALUE('Take + one down, pass it around, ') DCL VAR(&BEER3) TYPE(*CHAR) LEN(78) VALUE('Go + to the store and by some more... 99 + bottles of beer') DCL VAR(&BOTTLES) TYPE(*DEC) LEN(2 0) VALUE(99) DCL VAR(&XB) TYPE(*CHAR) LEN(2) DCL VAR(&RPY) TYPE(*CHAR) LEN(4) CHGVAR VAR(&XB) VALUE(&BOTTLES) MOREBEER: CHGVAR VAR(&MSG) VALUE(&XB *CAT &BEER1 *CAT &XB + *CAT %SST(&BEER1 1 16)) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) + TOPGMQ(*EXT) MSGTYPE(*STATUS) DLYJOB DLY(1) CHGVAR VAR(&BOTTLES) VALUE(&BOTTLES - 1) CHGVAR VAR(&XB) VALUE(&BOTTLES) CHGVAR VAR(&MSG) VALUE(&BEER2 *CAT &XB *CAT + %SST(&BEER1 1 28)) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) + TOPGMQ(*EXT) MSGTYPE(*STATUS) DLYJOB DLY(1) IF COND(&BOTTLES > 0) THEN(GOTO CMDLBL(MOREBEER)) CHGVAR VAR(&MSG) VALUE('No more' *CAT &BEER1 *CAT + 'no more' *CAT %SST(&BEER1 1 16)) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) + TOPGMQ(*EXT) MSGTYPE(*STATUS) DLYJOB DLY(2) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&BEER3) + TOPGMQ(*EXT) MSGTYPE(*INQ) KEYVAR(&RPY) ENDPGM
/* THIS IS WRITTEN IN CLIST - A IBM MVS/TSO BATCH LANGUAGE /* THIS LINE IS A COMMENT /* ALEX V FLINSCH<EMAIL_ADDRESS>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
/* 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 == 7) "7 bottle" if (i%10 == 8) "8 bottle" if (i%10 == 9) "9 bottle" if (i != 1) "s" " of beer. " 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
PUT "by Whitey<EMAIL_ADDRESS>- 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 num, " on the wall, ", verse num, "," / WRITE "take one down, pass it around," / PUT num - 1 IN num WRITE verse num, " on the wall." / DRINK
module NINTY_NINE_BOTTLES (main=BOTTLES) = ! ! "99 Bottles of Beer on the Wall" ! using BLISS on DIGITAL's Alpha OpenVMS ! by Ron Brender<EMAIL_ADDRESS>! begin forward routine BOTTLES : novalue, !  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(' "99 Bottles of Beer on the Wall"'); PUT_NL(); 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 eludomVersion #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<EMAIL_ADDRESS>! 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(' "99 Bottles of Beer on the Wall"'); PUT_NL(); PUT_NL(); BOTTLE_TEXT(99); end; end eludom
/* * 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"; }
## 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
io: MODULE /* The CHILL/2 compiler I use has no VARYING strings. To tackle this inconvenience, I declare a record with variants..  OD; END singTheSong; END beer;
\ Abundance version of 99 bottles of beer RG 2.0/1.0 97/03/08 <<<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 RFOR>>> >>>
$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";"nine"; "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;}
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 {<} return to calling cell "x bottles of beer." :24+11 {:}{.} print bottles of beer [0] string termination [10] "\n" [46][114][101][101][98][32][102][111][32] ".reeb fo " [12]{^}[1]{-}[4]{\}{!}{|} [115] "s" [1]{>}{#} [101][108][116][116][111][98][32] "elttob " [34]{>} call the printing part of the program {<} return to calling cell "Take one down, pass it around" :35 [0] string termination [10] "\n" [44][100][110][117][111][114][97][32][116][105][32] ",dnuora ti " [115][115][97][112][32][44][110][119][111][100][32] "ssap ,nwod " [101][110][111][32][101][107][97][84] "eno ekaT" [38]{>} goto the printing part of the program {<} return to calling cell "x-1 bottles of beer on the wall!" :38 [1]{-}{:}{.} (print bottles of beer)-1 [0] string termination [10] "\n" [10] "\n" [33][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 " [115][101][108][116][116][111][98][32] "selttob " [38]{>} goto the printing part of the program {<} return to calling cell "No bottles of beer on the wall!", terminating part of program :36 [0] string termination [10] "\n" [33][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 " [115][101][108][116][116][111][98][32][111][78] "selttob oN" [9]{>} 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 {<} return to calling cell
<HTML> <HEAD> <TITLE>99 Bottles of Beer</TITLE> </HEAD> <BODY> <!-- Microsoft ASP (Active Server Pages) listing by Vince Curley<EMAIL_ADDRESS>--> <% n = 99 do str = n & " bottle" if n <> 1 then str = str & "s" str = str & " of beer" Response.Write str & " on the wall...<BR>" Response.Write str & "!<BR>" Response.Write "Take one down, pass it around...<BR>" n = n - 1 if n > 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!<BR>" Response.Write str Response.Write "<BR>" loop while n > 0 Response.Write "<FONT SIZE=7><STRONG>Buy more beer!</STRONG></FONT>" %> </BODY> </HTML>
-- 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
>+++++++++[<+++++++++++>-]<[>[-]>[-]<<[>+>+<<-]>>[<<+>>-]>>> [-]<<<+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+< -]<<-<-]+++++++++>[<->-]>>+>[<[-]<<+>>>-]>[-]+<<[>+>-<<-]<<< [>>+>+<<<-]>>>[<<<+>>>-]>[<+>-]<<-[>[-]<[-]]>>+<[>[-]<-]<+++ +++++[<++++++<++++++>>-]>>>[>+>+<<-]>>[<<+>>-]<[<<<<<.>>>>>- ]<<<<<<.>>[-]>[-]++++[<++++++++>-]<.>++++[<++++++++>-]<++.>+ ++++[<+++++++++>-]<.><+++++..--------.-------.>>[>>+>+<<<-]> >>[<<<+>>>-]<[<<<<++++++++++++++.>>>>-]<<<<[-]>++++[<+++++++ +>-]<.>+++++++++[<+++++++++>-]<--.---------.>+++++++[<------ ---->-]<.>++++++[<+++++++++++>-]<.+++..+++++++++++++.>++++++ ++[<---------->-]<--.>+++++++++[<+++++++++>-]<--.-.>++++++++ [<---------->-]<++.>++++++++[<++++++++++>-]<++++.----------- -.---.>+++++++[<---------->-]<+.>++++++++[<+++++++++++>-]<-. >++[<----------->-]<.+++++++++++..>+++++++++[<---------->-]< -----.---.>>>[>+>+<<-]>>[<<+>>-]<[<<<<<.>>>>>-]<<<<<<.>>>+++ +[<++++++>-]<--.>++++[<++++++++>-]<++.>+++++[<+++++++++>-]<. ><+++++..--------.-------.>>[>>+>+<<<-]>>>[<<<+>>>-]<[<<<<++ ++++++++++++.>>>>-]<<<<[-]>++++[<++++++++>-]<.>+++++++++[<++ +++++++>-]<--.---------.>+++++++[<---------->-]<.>++++++[<++ +++++++++>-]<.+++..+++++++++++++.>++++++++++[<---------->-]< -.---.>+++++++[<++++++++++>-]<++++.+++++++++++++.++++++++++. ------.>+++++++[<---------->-]<+.>++++++++[<++++++++++>-]<-. -.---------.>+++++++[<---------->-]<+.>+++++++[<++++++++++>- ]<--.+++++++++++.++++++++.---------.>++++++++[<---------->-] <++.>+++++[<+++++++++++++>-]<.+++++++++++++.----------.>++++ +++[<---------->-]<++.>++++++++[<++++++++++>-]<.>+++[<-----> -]<.>+++[<++++++>-]<..>+++++++++[<--------->-]<--.>+++++++[< ++++++++++>-]<+++.+++++++++++.>++++++++[<----------->-]<++++ .>+++++[<+++++++++++++>-]<.>+++[<++++++>-]<-.---.++++++.---- ---.----------.>++++++++[<----------->-]<+.---.[-]<<<->[-]>[ -]<<[>+>+<<-]>>[<<+>>-]>>>[-]<<<+++++++++<[>>>+<<[>+>[-]<<-] >[<+>-]>[<<++++++++++>>>+<-]<<-<-]+++++++++>[<->-]>>+>[<[-]< <+>>>-]>[-]+<<[>+>-<<-]<<<[>>+>+<<<-]>>>[<<<+>>>-]<>>[<+>-]< <-[>[-]<[-]]>>+<[>[-]<-]<++++++++[<++++++<++++++>>-]>>>[>+>+ <<-]>>[<<+>>-]<[<<<<<.>>>>>-]<<<<<<.>>[-]>[-]++++[<++++++++> -]<.>++++[<++++++++>-]<++.>+++++[<+++++++++>-]<.><+++++..--- -----.-------.>>[>>+>+<<<-]>>>[<<<+>>>-]<[<<<<++++++++++++++ .>>>>-]<<<<[-]>++++[<++++++++>-]<.>+++++++++[<+++++++++>-]<- -.---------.>+++++++[<---------->-]<.>++++++[<+++++++++++>-] <.+++..+++++++++++++.>++++++++[<---------->-]<--.>+++++++++[ <+++++++++>-]<--.-.>++++++++[<---------->-]<++.>++++++++[<++ ++++++++>-]<++++.------------.---.>+++++++[<---------->-]<+. >++++++++[<+++++++++++>-]<-.>++[<----------->-]<.+++++++++++ ..>+++++++++[<---------->-]<-----.---.+++.---.[-]<<<]
; ASPECT version of 99 Bottles of beer ; (aspect is the scripting language of PROCOMM PLUS) ; This program requires Procomm Plus version 2.0 ; programmer: Michael LaGrasta<EMAIL_ADDRESS>proc main integer bottles string szVerse_a string szVerse_b string szChorus string szTemp_a string szTemp_b bottles = 99 szVerse_a = " bottles of beer" szVerse_b = " on the wall" szChorus = "Take one down and pass it around" numtostr bottles szTemp_a numtostr bottles szTemp_b strcat szTemp_a szVerse_a strcat szTemp_a szVerse_b termwrites szTemp_a termwritec 0x0d termwritec 11 strcat szTemp_b szVerse_a termwrites szTemp_b termwritec 0x0d termwritec 11 termwrites szChorus termwritec 0x0d termwritec 11 szTemp_a = "" bottles = bottles - 1 numtostr bottles szTemp_a strcat szTemp_a szVerse_a strcat szTemp_a szVerse_b termwrites szTemp_a termwritec 0x0d termwritec 11 termwritec 0x0d termwritec 11 szTemp_a = "" szTemp_b = "" while bottles > 2 numtostr bottles szTemp_a numtostr bottles szTemp_b strcat szTemp_a szVerse_a strcat szTemp_a szVerse_b termwrites szTemp_a termwritec 0x0d termwritec 11 strcat szTemp_b szVerse_a termwrites szTemp_b termwritec 0x0d termwritec 11 termwrites szChorus termwritec 0x0d termwritec 11 szTemp_a = "" bottles = bottles - 1 numtostr bottles szTemp_a strcat szTemp_a szVerse_a strcat szTemp_a szVerse_b termwrites szTemp_a termwritec 0x0d termwritec 11 termwritec 0x0d termwritec 11 szTemp_a = "" szTemp_b = "" endwhile termwrites "1 bottle of beer on the wall ?!?!" termwritec 0x0d termwritec 11 termwrites "Uh oh! LAST BOTTLE!" termwritec 0x0d termwritec 11 termwrites "I ain't passin' this one around!" termwritec 0x0d termwritec 11 termwrites "AAAAAAAAAAAAA!!! No more beer!!!" termwritec 0x0d termwritec 11 endproc
CDC = Control Data Corporation
NOS = Network Operating System
CCL = Cyber Control Language
It's the operating system control language of the cyber machine.
.PROC,DRV99*I, COUNT = (*N=10,*F). .HELP. THIS PROC READS ARGUMENT COUNT, AND INITIALIZES REGISTER COUNTER TO THAT VALUE. THEN THIS PROC LOOPS FOR THAT MANY COUNTS, DECREMENTING THE REGISTER COUNTER EVERY LOOP. DURING THE LOOP THIS PROC CALLS PRN99 WHICH PRINTS MESSAGE FOR THAT COUNT .HELP,COUNT. THIS IS THE INITITAL COUNT, THE COUNT FROM WHICH TO DECREMENT. .ENDHELP .IF,NUM(COUNT),QUIT. SET,R1=COUNT. SET,R2=0. WHILE,R1.GT.R2,LOOP. BEGIN,PRN99,DRV99,R1. SET,R1=R1-1. ENDW,LOOP. NOTE./NO BOTTLES OF BEER ON THE WALL REVERT,NOLIST. .ENDIF,QUIT. REVERT,ABORT. NONNUMERIC PASSES .PROC,PRN99*I,COUNT=(*N=10,*F). .SET,K9=STRD(COUNT).  { In BefDC - a derivative of Befudge and dc, by Sam Holden { This code by Sam Holden, 1997. { Note: this language was actually designed to do my cryptography assigments, which is why it is defined with 'infinite' precision math. { { { { bottles of beer on the wall Take one down, pass it around
bottles := 99; OPENWINDOW('##1# bottles of beer on the wall \'+ '##1# bottles of beer on the wall'); UPDATEWINDOW(1,bottles); REPEAT OPENWINDOW('Take one down, pass it around'); OPENWINDOW('##1# bottles of beer on the wall \'+ '##1# bottles of beer on the wall'); bottles := bottles -1; UPDATEWINDOW(1,bottles); UNTIL bottles = 1; OPENWINDOW('1 bottle of beer on the wall \'+ 'no more bottles of beer on the wall'); CLOSEWINDOW();
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 NEXTIn order to avoid slighting anyone, here is the QuickBasic version:
'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
<!--- 99 Bottles of Beer in Cold Fusion by Steven Reich<EMAIL_ADDRESS>---> <HTML> <HEAD> <TITLE>Bottles of Beer</TITLE> </HEAD> <BODY> <CFLOOP INDEX="idx" FROM=99 TO=2 STEP=-1> <CFOUTPUT> #idx# Bottles of Beer on the wall, #idx# Bottles of Beer, <BR>Take one down, pass it around, #Evaluate("#idx# - 1")# Bottles of Beer on the wall <P> </CFOUTPUT> </CFLOOP> 1 Bottle of Beer on the wall, 1 Bottle of Beer, <BR>Take one down, pass it around, no Bottles of Beer on the wall </BODY> </HTML>
{ 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_ADDRESS>} 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) ;
;;;; 99 bottles of beer as a CLOS program. ;;;; Author: Christopher Oliver<EMAIL_ADDRESS>;;;; 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 "~&~%")))))
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()
/* I made some changes to the miranda script by Tim Walls. Changes by Gavin Spearhead<EMAIL_ADDRESS>*/ 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
* 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 *<EMAIL_ADDRESS><macro=1><name="init beer"> 99<sp>bottles<sp>of<sp>beer<sp>on<sp>wall<enter>99<sp>bottles<sp>of<sp>beer <enter>Take<sp>one<sp>down,<sp>pass<sp>it<sp>around<enter>98<sp>bottles<sp> of<sp>beer<sp>on<sp>wall<enter> <macro=2><name="Drink one"> <up><up><up><up><mark down><mark down><mark down><mark down><copy><down> <enter><paste><decrement>1<enter><down><decrement>1<enter><down><down> <decrement>1<enter><down>
-- BEER.CAL --
; BEER.CAL by Tom Murphy 7-- PART1.CAL --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. ; <9.9.97> (do (int beer 99) (while (!= beer 0) (do (if (!= beer 1) (message beer "bottles of beer on the wall") (message "1 more bottle of beer on the wall...") ) (include "part1.cal") (if (!= beer 1) (message beer "bottles of beer") (message "1 more bottle of beer...") ) (delay 600) (include "part2.cal") (message "Take one down, pass it around") (delay 600) (include "part3.cal") (-- beer) (delay 600) (if (!= beer 1) (message beer "bottles of beer on the wall") (message "1 more bottle of beer on the wall...") ) (include "part4.cal") (delay 600) )) (pause "We're out of beer, dude.")  WRITE '' SONG END PERFORM LINES PERFORM LINE WRITE '1 BOTTLE OF BEER ON THE WALL.' WRITE '' WRITE '1 BOTTLE OF BEER ON THE WALL,' WRITE '1 BOTTLE OF BEER,' PERFORM LINE WRITE 'NO BOTTLES OF BEER ON THE WALL.' STOP
. 99 bottles of beer song . written for Babbage's Analytical Engine with Attendant . by Greg Cook 15/1/1998 . Attendant converts flow structure to conditional jumps . No new line after number A write in columns . constants N000 0 N001 1 N002 2 . bottle count N003 99 (? - L003 P . finish subtraction to compare bottles to 1 L002 {? A write annotation bottles }{ A write annotation bottle } A write annotation of beer on the wall, A write new line . new subtraction card to clear mill - L003 P L002 {?  Still subtracting, update counter L003 L001 S003 . compare for 0 this time L003 L001 {? . if <=0 then don't finish verse - L003 P L002 {?  A write new line A write new line } . if >0 then continue loop L000 L003 ) A write annotation No more bottles of beer on the wall! A write new line
/* DAL version of 99 Bottles of beer programmer: by Georg Hentsch<EMAIL_ADDRESS>*/ 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); }
@echo off REM 99 Bottles of Beer in DOS Batch REM Gert-jan Los<EMAIL_ADDRESS>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
C patrick m. ryan<EMAIL_ADDRESS>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 version of the 99 Bottles program. \ Dan Reish<EMAIL_ADDRESS>: .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 ." No more bottles of beer on the wall." THEN CR ; : nbottles ( n -- ) BEGIN .bottles ?dup NOT UNTIL ; 99 nbottles
C Allen Mcintosh C<EMAIL_ADDRESS>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
;;Geza Gyuk -<EMAIL_ADDRESS>(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))))))
! Does the beer song... sends output to a postscript file ! Geza Gyuk -<EMAIL_ADDRESS>printer 1 erase data beer.dat setv rounds c1(1) ! get number of rounds ! from first line, first setv container bottles ! column of file beer.dat 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 0.1 {5/(5*rounds)} putlabel 6 1 bottle of beer on the wall, relocate 0.1 {4/(5*rounds)} putlabel 6 1 bottle of beer, relocate 0.1 {3/(5*rounds)} putlabel 6 take it down and pass it around, relocate 0.1 {2/(5*rounds)} putlabel 6 no more bottles of beer on the wall. hardcopy end
{----------------------------------------------------------------------} {Contents of BEER99.DPR} program Beer99; {99 bottles of beer - Borland Delphi 1.0} {by Rodney M. Savard<EMAIL_ADDRESS>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 version of 99 Bottles of Beer // programmer: Jim Studt<EMAIL_ADDRESS>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;
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 BEERSHere 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 version of the beer song % Kent Engström<EMAIL_ADDRESS>% --------------------------------------------------------------- % 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").
01.10 c Focal-8 version of 99 Bottles of beer 01.20 c Hacked by Akira KIDA<EMAIL_ADDRESS>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 set b = i 30.20 do 40 ; type " on the wall, " 30.30 do 40 ; type ".", ! , "Take one down, pass it around.", ! 30.40 set b = i - 1 30.50 do 40 ; type " on the wall.", !, ! 30.60 return 40.10 do 50 40.20 type " of beer" 40.30 return 50.10 if (b - 1) 50.20, 50.40, 50.60 50.20 type "No more bottles" 50.30 return 50.40 type %1.0, b, " bottle" 50.50 return 50.60 type %1.0, b, " bottles" 50.70 return
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 version of 99 Bottles by Marcus Comstedt<EMAIL_ADDRESS>} [$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 Version of 99 Bottles of Beer : RAM-Biter!!! ! Tested on a SPARC classic, SunSolaris 2 ! Programmer: Wolfgang Lohmann<EMAIL_ADDRESS>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 ) <= w ; --- app (( a :: v ), w ) <=( a :: app ( v , w )) ; --- i2c(0) <= '0'; --- i2c(1) <= '1'; --- i2c(2) <= '2'; --- i2c(3) <= '3'; --- i2c(4) <= '4'; --- i2c(5) <= '5'; --- i2c(6) <= '6'; --- i2c(7) <= '7'; --- i2c(8) <= '8'; --- i2c(9) <= '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 program for the Beer Song. -- -- Bert Thompson 5.11.95<EMAIL_ADDRESS>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"
! F90 (Fortran 90) version of 99 bottles of beer. ! written by Akira KIDA<EMAIL_ADDRESS>! 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
.TITLE - "Program to display 99 bottles of beer on the wall" ; ;======================================================================================================= ; Author: Bob Welton<EMAIL_ADDRESS>; Projects Unlimited Inc. ; Dayton, OH 45414 ; ; Language: DIBOL or DBL ;======================================================================================================= RECORD MISC NUMBOTTLES ,D2,99 ;Default # of bottles to 99 ANUMBOTTLES ,A2 ;Used to mask the output of bottles .PROC XCALL FLAGS<PHONE_NUMBER>,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
&& BEER.PRG - 99 Bottles of Beer - Brian Hobbs Jan 1996 &&<EMAIL_ADDRESS>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
-- 99 bottles of beer (gofer version) -- Written by Bow-Yaw Wang<EMAIL_ADDRESS>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
# Programmer: Mark Gray -<EMAIL_ADDRESS># 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
-- -- a version of the "99 bottles of beer" song in HyperTalk -- by eric carlson<EMAIL_ADDRESS>-- on BeerSong99 BottlesOfBeer 99 end BeerSong99 -- -- do something with a lyric from the beer song. this handler adds it to -- a field on the current card on OutputBeerLyric beerString if ( beerString is "<reset>" ) then put empty into cd fld "beer song" 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
** 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
\ 99 bottles of beer in Froth, by Leo Wong, a teetotaler 6FEB96 + \ Pass it around. : LYRICS [CHAR] ! PARSE TUCK HERE CHAR+ SWAP CHARS MOVE DUP C, CHARS ALLOT ; : VOCALIZE ( a) COUNT TYPE ; : SING CREATE LYRICS DOES> VOCALIZE ; SING NO_MORE No more ! SING BOTTLE bottle! SING BOTTLES bottles! SING OF_BEER of beer! SING ON_THE_WALL on the wall! SING TAKE Take ! SING IT it! SING ONE one! SING DOWN_AND_PASS_IT_AROUND down and pass it around! SING GO_TO_THE_STORE_&_BUY_SOME_MORE Go to the store and buy some more! SING COMMA ,! SING PERIOD .! : ?: CREATE ( n) , ' , ' , DOES> ( n) TUCK @ <> 1- CELLS - @ EXECUTE ; : NONE ( n) DROP NO_MORE ; : SOME ( n) . ; 0 ?: HOW_MANY NONE SOME 1 ?: BOTTLE(S) BOTTLE BOTTLES 1 ?: IT|ONE IT ONE : COMMERCIAL ( 0 - 99) GO_TO_THE_STORE_&_BUY_SOME_MORE 99 + ; : SHAREWARE ( n - n-1) DUP TAKE IT|ONE DOWN_AND_PASS_IT_AROUND 1- ; 0 ?: main(){0?99:--} COMMERCIAL SHAREWARE : BURP ( n - n n) DUP ; : HOW_MANY_BOTTLES_OF_BEER ( n n n) HOW_MANY BOTTLE(S) OF_BEER ; : Froth ( n - n') CR BURP BURP BURP HOW_MANY_BOTTLES_OF_BEER ON_THE_WALL COMMA CR BURP BURP BURP HOW_MANY_BOTTLES_OF_BEER COMMA CR BURP main(){0?99:--} COMMA CR BURP BURP BURP HOW_MANY_BOTTLES_OF_BEER ON_THE_WALL PERIOD CR ; : LeoWong ( n) DROP ; : SONG 99
/* 99 Bottles of Beer */ /* James Hicks<EMAIL_ADDRESS>*/ /* 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;
#!/usr/local/bin/expect # 99 bottles of beer on the wall, Expect-style # Author: Don LibesSample output:# 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 arr1 [expr .4 - ($i/333.)] set arr2 [expr .6 - ($i/333.)] set shape [expr log(($i+2)/2.)+.1] set min 0 set 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} {$i>0} {} { 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]] } }
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.
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)
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
/************************************************************************/ /* bottle.cpp */ /* 1996 Walter Zimmer<EMAIL_ADDRESS>*/ /* */ /* 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 < 10 /* Use SECONDTEN */ print(TENS,ONES) print(TENS,ONES) Take one down, pass it around print(SECONDTEN,SECONDONE) #endif /* SECONDTEN */ #else /* ONES */ /* Here everthing is normal, we use the normal TENS */ print(TENS,ONES) print(TENS,ONES) Take one down, pass it around print(TENS,SECONDONE) #endif /* ONES */ #elif defined LOOP /* This is the inner loop which iterates about the last digit */ /* #undef LOOP, #define TEXT so we output text in the next #include */ #undef LOOP #define TEXT /* #undef and #define the inner digits, invoke text output */ #undef ONES #undef SECONDONE #define ONES 9 #define SECONDONE 8 #include "bottle.cpp" /* ...and so on for digits 8-0 */ #undef ONES #undef SECONDONE #define ONES 8 #define SECONDONE 7 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 7 #define SECONDONE 6 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 6 #define SECONDONE 5 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 5 #define SECONDONE 4 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 4 #define SECONDONE 3 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 3 #define SECONDONE 2 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 2 #define SECONDONE 1 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 1 #define SECONDONE 0 #include "bottle.cpp" #undef ONES #undef SECONDONE #define ONES 0 #define SECONDONE 9 #include "bottle.cpp" /* Clean up */ #undef TEXT #else /* TEXT, LOOP */ /* Here is the basic 'loop' which iterates about the outer digit */ /* First define the print macro which outputs one line of xx beer */ /* We have to define it over the second define 'raw' to combine */ /* prescan with concatenation */ #define raw(TENS,ONES) TENS ## ONES #define print(TENS,ONES) raw(TENS,ONES) bottles of beer on the wall /* Tell bottle.cpp to invoke the inner loop when #included */ #define LOOP /* #define outer digit and process inner loop */ #define TENS 9 #define SECONDTEN 8 #include "bottle.cpp" /* Do this for the other digits 8 to 0, now with #undef */ /* Since LOOP gets #undef'd, we have to define it again */ #define LOOP #undef TENS #define TENS 8 #undef SECONDTEN #define SECONDTEN 7 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 7 #undef SECONDTEN #define SECONDTEN 6 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 6 #undef SECONDTEN #define SECONDTEN 5 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 5 #undef SECONDTEN #define SECONDTEN 4 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 4 #undef SECONDTEN #define SECONDTEN 3 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 3 #undef SECONDTEN #define SECONDTEN 2 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 2 #undef SECONDTEN #define SECONDTEN 1 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 1 #undef SECONDTEN #define SECONDTEN 0 #include "bottle.cpp" #define LOOP #undef TENS #define TENS 0 #undef SECONDTEN /* We @define SECONDTEN as 10 to indicate that we are outputting */ /* the last block and therefore need only 9 verses */ #define SECONDTEN 10 #include "bottle.cpp" #endif
* EXEC version of 99 Bottles of beer program * By Torbjørn Vaaje<EMAIL_ADDRESS>* &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
-* 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!
" 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
Sub Beers() ' 99 bottles of beer on the wall ' Visual Basic for Excel version ' by Alejandro Julien<EMAIL_ADDRESS>' 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
[ 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<EMAIL_ADDRESS>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
99 Bottles of Beer on the Wall (I-M)
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<EMAIL_ADDRESS>*) 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 -<EMAIL_ADDRESS>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<EMAIL_ADDRESS>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 #<EMAIL_ADDRESS>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"<EMAIL_ADDRESS># 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<EMAIL_ADDRESS>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_ADDRESS>*/ 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 <- #1 PLEASE DO ,10SUB#1 <- #176 PLEASE DO ,11 <- #30 PLEASE DO ,11SUB#1 <- #76 DO ,11SUB#2 <- #190 DO ,11SUB#3 <- #80 DO ,11SUB#4 <- #200 PLEASE DO ,11SUB#5 <- #256 DO ,11SUB#6 <- #248 DO ,11SUB#7 <- #144 DO ,11SUB#8 <- #216 PLEASE DO ,11SUB#9 <- #202 DO ,11SUB#10 <- #14 DO ,11SUB#11 <- #144 DO ,11SUB#12 <- #98 PLEASE DO ,11SUB#13 <- #190 DO ,11SUB#14 <- #160 DO ,11SUB#15 <- #256 DO ,11SUB#16 <- #88 PLEASE DO ,11SUB#17 <- #74 DO ,11SUB#18 <- #14 DO ,11SUB#19 <- #128 DO ,11SUB#20 <- #114 PLEASE DO ,11SUB#21 <- #214 DO ,11SUB#22 <- #24 DO ,11SUB#23 <- #112 DO ,11SUB#24 <- #162 PLEASE DO ,11SUB#25 <- #22 DO ,11SUB#26 <- #104 DO ,11SUB#27 <- #80 DO ,11SUB#28 <- #256 PLEASE DO ,11SUB#29 <- #2 DO ,11SUB#30 <- #228 PLEASE DO ,12 <- #49 PLEASE DO ,12SUB#1 <- #76 DO ,12SUB#2 <- #190 DO ,12SUB#3 <- #80 DO ,12SUB#4 <- #200 PLEASE DO ,12SUB#5 <- #256 DO ,12SUB#6 <- #248 DO ,12SUB#7 <- #144 DO ,12SUB#8 <- #216 PLEASE DO ,12SUB#9 <- #202 DO ,12SUB#10 <- #14 DO ,12SUB#11 <- #144 DO ,12SUB#12 <- #98 PLEASE DO ,12SUB#13 <- #190 DO ,12SUB#14 <- #160 DO ,12SUB#15 <- #256 DO ,12SUB#16 <- #88 PLEASE DO ,12SUB#17 <- #218 DO ,12SUB#18 <- #36 DO ,12SUB#19 <- #38 DO ,12SUB#20 <- #164 PLEASE DO ,12SUB#21 <- #176 DO ,12SUB#22 <- #48 DO ,12SUB#23 <- #162 DO ,12SUB#24 <- #14 PLEASE DO ,12SUB#25 <- #128 DO ,12SUB#26 <- #208 DO ,12SUB#27 <- #162 DO ,12SUB#28 <- #222 PLEASE DO ,12SUB#29 <- #48 DO ,12SUB#30 <- #8 DO ,12SUB#31 <- #120 DO ,12SUB#32 <- #66 PLEASE DO ,12SUB#33 <- #48 DO ,12SUB#34 <- #246 DO ,12SUB#35 <- #136 DO ,12SUB#36 <- #184 PLEASE DO ,12SUB#37 <- #256 DO ,12SUB#38 <- #202 DO ,12SUB#39 <- #110 DO ,12SUB#40 <- #104 PLEASE DO ,12SUB#41 <- #42 DO ,12SUB#42 <- #126 DO ,12SUB#43 <- #56 DO ,12SUB#44 <- #88 PLEASE DO ,12SUB#45 <- #72 DO ,12SUB#46 <- #56 DO ,12SUB#47 <- #80 DO ,12SUB#48 <- #242 PLEASE DO ,12SUB#49 <- #228 PLEASE DO ,13 <- #31 PLEASE DO ,13SUB#1 <- #76 DO ,13SUB#2 <- #190 DO ,13SUB#3 <- #80 DO ,13SUB#4 <- #200 PLEASE DO ,13SUB#5 <- #256 DO ,13SUB#6 <- #248 DO ,13SUB#7 <- #144 DO ,13SUB#8 <- #216 PLEASE DO ,13SUB#9 <- #202 DO ,13SUB#10 <- #14 DO ,13SUB#11 <- #144 DO ,13SUB#12 <- #98 PLEASE DO ,13SUB#13 <- #190 DO ,13SUB#14 <- #160 DO ,13SUB#15 <- #256 DO ,13SUB#16 <- #88 PLEASE DO ,13SUB#17 <- #74 DO ,13SUB#18 <- #14 DO ,13SUB#19 <- #128 DO ,13SUB#20 <- #114 PLEASE DO ,13SUB#21 <- #214 DO ,13SUB#22 <- #24 DO ,13SUB#23 <- #112 DO ,13SUB#24 <- #162 PLEASE DO ,13SUB#25 <- #22 DO ,13SUB#26 <- #104 DO ,13SUB#27 <- #80 DO ,13SUB#28 <- #256 PLEASE DO ,13SUB#29 <- #194 DO ,13SUB#30 <- #36 DO ,13SUB#31 <- #256 PLEASE DO ,20 <- #10 PLEASE DO ,20 SUB #1 <- #76 DO ,20 SUB #2 <- #196 DO ,20 SUB #3 <- #4 DO ,20 SUB #4 <- #132 PLEASE DO ,20 SUB #5 <- #36 DO ,20 SUB #6 <- #164 DO ,20 SUB #7 <- #228 DO ,20 SUB #8 <- #100 PLEASE DO ,20 SUB #9 <- #52 DO ,20 SUB #10 <- #180 PLEASE DO ,21 <- #10 BY #10 PLEASE DO ,21SUB#1#1 <- #248 PLEASE DO ,21SUB#1#2 <- #120 PLEASE DO ,21SUB#1#3 <- #184 PLEASE DO ,21SUB#1#4 <- #56 PLEASE DO ,21SUB#1#5 <- #216 PLEASE DO ,21SUB#1#6 <- #88 PLEASE DO ,21SUB#1#7 <- #152 PLEASE DO ,21SUB#1#8 <- #24 PLEASE DO ,21SUB#1#9 <- #232 PLEASE DO ,21SUB#1#10 <- #104 DO ,21SUB#2#1 <- #128 DO ,21SUB#2#2 <- #256 DO ,21SUB#2#3 <- #64 DO ,21SUB#2#4 <- #192 DO ,21SUB#2#5 <- #96 DO ,21SUB#2#6 <- #224 DO ,21SUB#2#7 <- #32 DO ,21SUB#2#8 <- #160 DO ,21SUB#2#9 <- #112 DO ,21SUB#2#10 <- #240 DO ,21SUB#3#1 <- #64 DO ,21SUB#3#2 <- #192 DO ,21SUB#3#3 <- #256 DO ,21SUB#3#4 <- #128 DO ,21SUB#3#5 <- #32 DO ,21SUB#3#6 <- #160 DO ,21SUB#3#7 <- #224 DO ,21SUB#3#8 <- #96 DO ,21SUB#3#9 <- #48 DO ,21SUB#3#10 <- #176 DO ,21SUB#4#1 <- #192 DO ,21SUB#4#2 <- #64 DO ,21SUB#4#3 <- #128 DO ,21SUB#4#4 <- #256 DO ,21SUB#4#5 <- #160 DO ,21SUB#4#6 <- #32 DO ,21SUB#4#7 <- #96 DO ,21SUB#4#8 <- #224 DO ,21SUB#4#9 <- #176 DO ,21SUB#4#10 <- #48 PLEASE DO ,21SUB#5#1 <- #32 PLEASE DO ,21SUB#5#2 <- #160 PLEASE DO ,21SUB#5#3 <- #224 PLEASE DO ,21SUB#5#4 <- #96 PLEASE DO ,21SUB#5#5 <- #256 PLEASE DO ,21SUB#5#6 <- #128 PLEASE DO ,21SUB#5#7 <- #192 PLEASE DO ,21SUB#5#8 <- #64 PLEASE DO ,21SUB#5#9 <- #16 PLEASE DO ,21SUB#5#10 <- #144 DO ,21SUB#6#1 <- #160 DO ,21SUB#6#2 <- #32 DO ,21SUB#6#3 <- #96 DO ,21SUB#6#4 <- #224 DO ,21SUB#6#5 <- #128 DO ,21SUB#6#6 <- #256 DO ,21SUB#6#7 <- #64 DO ,21SUB#6#8 <- #192 DO ,21SUB#6#9 <- #144 DO ,21SUB#6#10 <- #16 DO ,21SUB#7#1 <- #96 DO ,21SUB#7#2 <- #224 DO ,21SUB#7#3 <- #32 DO ,21SUB#7#4 <- #160 DO ,21SUB#7#5 <- #64 DO ,21SUB#7#6 <- #192 DO ,21SUB#7#7 <- #256 DO ,21SUB#7#8 <- #128 DO ,21SUB#7#9 <- #80 DO ,21SUB#7#10 <- #208 DO ,21SUB#8#1 <- #224 DO ,21SUB#8#2 <- #96 DO ,21SUB#8#3 <- #160 DO ,21SUB#8#4 <- #32 DO ,21SUB#8#5 <- #192 DO ,21SUB#8#6 <- #64 DO ,21SUB#8#7 <- #128 DO ,21SUB#8#8 <- #256 DO ,21SUB#8#9 <- #208 DO ,21SUB#8#10 <- #80 PLEASE DO ,21SUB#9#1 <- #16 PLEASE DO ,21SUB#9#2 <- #144 PLEASE DO ,21SUB#9#3 <- #208 PLEASE DO ,21SUB#9#4 <- #80 PLEASE DO ,21SUB#9#5 <- #240 PLEASE DO ,21SUB#9#6 <- #112 PLEASE DO ,21SUB#9#7 <- #176 PLEASE DO ,21SUB#9#8 <- #48 PLEASE DO ,21SUB#9#9 <- #256 PLEASE DO ,21SUB#9#10 <- #128 DO ,21SUB#10#1 <- #144 DO ,21SUB#10#2 <- #16 DO ,21SUB#10#3 <- #80 DO ,21SUB#10#4 <- #208 DO ,21SUB#10#5 <- #112 DO ,21SUB#10#6 <- #240 DO ,21SUB#10#7 <- #48 DO ,21SUB#10#8 <- #176 DO ,21SUB#10#9 <- #128 DO ,21SUB#10#10 <- #256 PLEASE DO ,22 <- #10 PLEASE DO ,22 SUB #1 <- #8 DO ,22 SUB #2 <- #136 DO ,22 SUB #3 <- #72 DO ,22 SUB #4 <- #200 PLEASE DO ,22 SUB #5 <- #40 DO ,22 SUB #6 <- #168 DO ,22 SUB #7 <- #104 DO ,22 SUB #8 <- #232 PLEASE DO ,22 SUB #9 <- #24 DO ,22 SUB #10 <- #152 DO .10 <- #9 DO .11 <- #9 PLEASE DO ,10 <- #1 PLEASE DO ,10SUB#1 <- #176 DO READ OUT ,10 DO COME FROM (999) DO (500) NEXT PLEASE DO ,11SUB#1 <- .5 DO READ OUT ,11 DO (500) NEXT DO ,12SUB#1 <- .5 PLEASE DO READ OUT ,12 PLEASE DO .6 <- '?"!10~.10'~#1"$#1'~#3 DO (50) NEXT PLEASE DO .7 <- '?"!11~.11'~#1"$#1'~#3 DO (70) NEXT DO .2 <- #1 DO .1 <- .11 PLEASE DO (1010) NEXT DO .11 <- .3 DO (600) NEXT DO (101) NEXT (70) DO (71) NEXT DO .11 <- #9 DO .2 <- #1 PLEASE DO .1 <- .10 DO (1010) NEXT DO .10 <- .3 DO (600) NEXT DO (101) NEXT (71) DO RESUME .7 (50) DO (51) NEXT PLEASE DO FORGET #1 DO .2 <- #1 DO .1 <- .11 PLEASE DO (1010) NEXT DO .11 <- .3 DO (600) NEXT PLEASE DO .7 <- '?"!11~.11'~#1"$#1'~#3 DO (80) NEXT DO (101) NEXT (80) DO (81) NEXT DO GIVE UP (81) DO RESUME .7 (51) DO RESUME .6 (101) DO FORGET #1 (999) DO FORGET #1 (600) DO (500) NEXT DO ,13SUB#1 <- .5 DO READ OUT ,13 DO RESUME #1 (500) DO ,30 <- #1 DO .1 <- .10 DO (1020) NEXT PLEASE DO ,30SUB#1 <- ,20SUB.1 DO READ OUT ,30 DO .3 <- .1 DO .1 <- .11 DO (1020) NEXT PLEASE DO ,30SUB#1 <- ,21SUB .3 .1 DO READ OUT ,30 DO .5 <- ,22SUB.1 PLEASE DO RESUME #1
Icon
# Scott E Gilbert<EMAIL_ADDRESS>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 i>1, 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<EMAIL_ADDRESS>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 WordSub MAIN REM "99 bottles of beer on the wall" REM Microsoft Word WordBasic macro language version REM written by Mark Pilgrim<EMAIL_ADDRESS>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[i>1, 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 -<EMAIL_ADDRESS>!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<EMAIL_ADDRESS>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<EMAIL_ADDRESS># 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` bottles endif
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<EMAIL_ADDRESS># 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<EMAIL_ADDRESS>*) (* 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<EMAIL_ADDRESS>% 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<EMAIL_ADDRESS>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<EMAIL_ADDRESS>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 "Z-machine" 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<EMAIL_ADDRESS>; 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<EMAIL_ADDRESS>; 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!  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_ADDRESS>* * 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 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 .  ISM/SML (for Integrated System Management / System Management Language).; Code Begin<EMAIL_ADDRESS>(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_ADDRESS>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_ADDRESS>} 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 bottleLeft>0 do begin print(bottleLeft); print(verse1); print(bottleLeft); print(verse2); bottleLeft := bottleLeft - 1; if (bottleLeft>0) 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 (bottleLeft>0) 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 num>1 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 <- total | pickBottle(left, total-1); end; function consume (i : integer)->relation; begin print(i); print(verse1); print(i); print(verse2); if i>1 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 ;check for last stanza :%A="" ;if last stanza clear plural s//%2 bottle%A of beer on the wall.<</ ;last line and blank line :%1=%1-1 ;check for end :on -1 /-9 ;if not end then loop s//No more bottles of beer on the wall.</ ;ending line /t/p/wo/song.txt/t/gd ;print, save and end (optional)
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 i>1: & "s" fi & " of beer on the wall,"; message decimal i & " bottle" if i>1: & "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* ILE RPG/400 - 99 Bottles of Beer on the Wall. A* (IBM AS/400 Midrange Platform) A* (Display File Source BOTTLESS1) A* A DSPSIZ(24 80 *DS3) A R #DISPLAY FRCDTA A A BOTTLES1 2Y 0O 4 2EDTCDE(4) A 4 5'Bottles of Beer On the Wall,' A BOTTLES2 2Y 0O 4 34EDTCDE(4) A 4 37'Bottles of Beer,' A 5 2'Take one down, pass it around.' A
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<EMAIL_ADDRESS>* * 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<EMAIL_ADDRESS>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<EMAIL_ADDRESS>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 $(<) on the wall!" ; } if ( $(b) = 0 ) { EXIT "No more $(<)!" ; } ECHO "$(b) bottles of $(<) on the wall. $(b) bottles of $(<). Take one down," ; ECHO "pass it around..." ; } } } Drink beer ;
Kermit Script
In case you missed it, Kermit is the communications program that seems to have been ported to just about everything, from the Timex Sinclair to the Cray II.comment --- 99 bottles of beer, in Kermit scripting language. comment --- Execute by using the TAKE command in Kermit, or naming comment --- this file with the default initialization file name. comment --- 23-Sep-1997 --- Scott Snadow<EMAIL_ADDRESS>set count 99 :loop if < \v(count) 99 echo \v(count) bottle(s) of beer on the wall. echo echo \v(count) bottle(s) of beer on the wall, \v(count) bottle(s) of beer. echo Take one down, pass it around, if count goto loop echo No bottles of beer on the wall.
Navel
# Bottles of beer in Navel Greg Michaelson<EMAIL_ADDRESS># 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 of beer on the wall, ', bottles, ' bottles of beer.'); Write('Take one down, pass it around, '); bottles := bottles-1; WriteLn(bottles, ' bottles of beer on the wall.'); until (bottles = 1); WriteLn('1 bottle of beer on the wall, one bottle of beer.'); WriteLn('Take one down, pass it around,' ' no more bottles of beer on the wall') end.---- 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 % left margin /ypos 720 def % initial top position /BM 72 def % bottom margin /lineheight 18 def % 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<EMAIL_ADDRESS>*/ 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 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_ADDRESS>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<PHONE_NUMBER> 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