|
// C++ version of 99 Bottles of beer // programmer: Tim Robinson timtroyr@ionet.net #include <fstream.h> int main() { int bottles = 99; while ( bottles > 0 ) { cout << bottles << " bottle(s) of beer on the wall," << endl; cout << bottles << " bottle(s) of beer." << endl; cout << "Take one down, pass it around," << endl; cout << --bottles << " bottle(s) of beer on the wall." << endl; } return 0; }
This is how C++ is supposed to be used.
// C++ version of 99 Bottles of Beer, object oriented paradigm // programmer: Tim Robinson timtroyr@ionet.net #include <fstream.h> enum Bottle { BeerBottle }; class Shelf { unsigned BottlesLeft; public: Shelf( unsigned bottlesbought ) : BottlesLeft( bottlesbought ) {} void TakeOneDown() { if (!BottlesLeft) throw BeerBottle; BottlesLeft--; } operator int () { return BottlesLeft; } }; int main( int, char ** ) { Shelf Beer(99); try { for (;;) { char *plural = (int)Beer !=1 ? "s" : ""; cout << (int)Beer << " bottle" << plural << " of beer on the wall," << endl; cout << (int)Beer << " bottle" << plural << " of beer," << endl; Beer.TakeOneDown(); cout << "Take one down, pass it around," << endl; plural = (int)Beer !=1 ? "s":""; cout << (int)Beer << " bottle" << plural << " of beer on the wall." << endl; } } catch ( Bottle ) { cout << "Go to the store and buy some more," << endl; cout << "99 bottles of beer on the wall." << endl; } return 0; }And one more version that may be called "abuse" by some, but here it is:
// 99 bottles of beer, C++ template 'meta-programming' version // By Arion Lei (philipl@cs.ust.hk) #include <iostream.h> template<int I> class Loop { public: static inline void f () { cout << I << " bottles of beer on the wall," << endl << I << " bottles of beer." << endl << "Take one down, pass it around," << endl << I-1 << " bottles of beer on the wall." << endl; Loop<I-1>::f(); } }; class Loop<0> { public: static inline void f () { cout << "Go to the store and buy some more," << endl << "99 bottles of beer on the wall." << endl; } }; int main () { Loop<3>::f(); return 0; }
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: bearheart@bearnet.com * */ #define MAXBEER (99) void chug(int beers); main() { register beers; for(beers = MAXBEER; beers; chug(beers--)) puts(""); puts("\nTime to buy more beer!\n"); exit(0); } void chug(register beers) { char howmany[8], *s; s = beers != 1 ? "s" : ""; printf("%d bottle%s of 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 tmoran@bix.com with Text_IO; procedure Bar is Out_Of_Beer : Exception; protected Bartender is function Count return Integer; procedure Take_One_Down; private Remaining : Integer range 0 .. 99 := 99; end Bartender; protected body Bartender is function Count return Integer is begin return Remaining; end Count; procedure Take_One_Down is begin if Remaining = 0 then raise Out_Of_Beer; else Remaining := Remaining - 1; end if; end Take_One_Down; end Bartender; type Names is (Charles, Ada, John, Grace, Donald, Edsger, Niklaus, Seymour, Fred, Harlan); task type Customers is entry Enter_Bar(Who : in Names); end Customers; Customer_List : array(Names) of Customers; task body Customers is Me : Names; procedure Sing_And_Drink(Singer_ID : in String) is procedure Sing(S : in String) renames Text_IO.Put_Line; begin loop declare Bottle_Part : constant String := Integer'image(Bartender.Count) & " bottles of beer"; begin Sing(Bottle_Part & " on the wall" & Singer_ID); Sing(Bottle_Part & Singer_ID); end; Sing(" Take one down and pass it arround" & Singer_ID); Bartender.Take_One_Down; delay 10.0; -- allow ten seconds to gulp one down end loop; exception when Out_Of_Beer => Sing("no more beer!" & Singer_ID); end Sing_And_Drink; begin -- customer task accept Enter_Bar(Who : in Names) do Me := Who; end Enter_Bar; Sing_And_Drink(" - " & Names'image(Me)); end Customers; begin -- operating bar for Person in Customer_List'range loop Customer_List(Person).Enter_Bar(Person); delay 2.0; -- allow two seconds between customers entering bar end loop; end Bar;
#!/bin/csh # # C-Shell script version of 99 Bottles of Beer # set i = 100 while ($i > 0) echo -n $i " bottles of beer on the wall" echo $i " bottles of beer......" set i = `expr $i - 1` echo -n "take one down pass it around, " $i echo "bottles of beer on the wall" end
--- A noteworthy alternative
#!/bin/csh # Version #2.1 C-Shell version of 99 Bottles of Beer # # overhauled 1997-19-3 by Ken Bateman (kbateman@esinet.net) # foreach i (9 8 7 6 5 4 3 2 1 " ") foreach j (9 8 7 6 5 4 3 2 1 0) if ( $i$j != "99" ) echo $i$j " bottles of beer on the wall" echo -n $i$j "bottles of beer on the wall, " echo $i$j "bottles of beer" echo -n "Take one down, pass it around..." end end echo "no more bottles of beer on the wall" echo "No more bottles of beer on the wall, no more bottles of beer" echo "Go to the store, buy some more," echo "99 bottles of beer on the wall" #end of script
#!/usr/bin/awk -f # awk version of 99 bottles of beer # by Whitey (whitey@netcom.com) - 06/05/95 BEGIN { for(i = 99; i > 0; i--) { print s = bottle(i), "on the wall,", s "," print "take one down, pass it around," print bottle(i - 1), "on the wall." } } function bottle(n) { return sprintf("%s bottle%s of beer", n ? n : "no more", n - 1 ? "s" : "") }
#!/bin/sh # Bourne shell version of 99 Bottles # Craig J Copi - copi@oddjob.uchicago.edu # if [ $# -eq 1 ]; then beers=$1 else beers=99 fi s="s" while [ $beers -gt 0 ]; do echo "$beers bottle$s of beer on the wall," echo "$beers bottle$s of beer," echo "take one down, pass it around," beers=`expr $beers - 1` if [ $beers -ne 0 ]; then test $beers -eq 1 && s="" echo "$beers bottle$s of beer on the wall." else echo "no bottles of beer on the wall." fi echo done echo echo "Time to buy some more beer . . . ."
;; Bottles by Rebecca Walpole (walpolr@cs.orst.edu) ;; tested in Austin Kyoto Common Lisp version 1.615 ;; Note: the ~p takes care of plurals. ;; (defun bottles (n) "Prints the lyrics to '99 Bottles of Beer'" (if (< n 1) (format t "~%Time to go to the store.~%") (progn (format t "~% ~a bottle~:p of beer on the wall." n) (format t "~% ~a bottle~:p of beer." n) (format t "~% Take one down, pass it around.") (format t "~% ~a bottle~:p of beer on the wall.~%" (- n 1)) (bottles (- n 1)) ) ) ) (bottles 99)
/* AML (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 <Otto.Stolz@Uni-Konstanz.de> # ( 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 kdj@mindspring.com to createBottleString for aNumberOfBottles if aNumberOfBottles is 0 then return "No more bottles" else if aNumberOfBottles is 1 then return "1 more bottle" else return (aNumberOfBottles as string) & " bottles" end if end createBottleString set lyrics to "" repeat with numberOfBottles from 99 to 1 by -1 set bottleString to (createBottleString for numberOfBottles) set lyrics to lyrics & bottleString & " of beer on the wall, " & bottleString & " of beer. " & return set lyrics to lyrics & "Take one down and pass it around, " & return set lyrics to lyrics & (createBottleString for (numberOfBottles - 1)) & " of beer on the wall. " & return end repeat set lyrics to lyrics & "No more bottles of beer on the wall, no more bottles of beer." & return set lyrics to lyrics & "Go to the store and buy some more." & return set lyrics to lyrics & "99 bottles of beer on the wall." return lyrics
// BCPL version of 99 Bottles of Beer. // hacked by Akira KIDA <SDI00379@niftyserve.or.jp> GET "LIBHDR" MANIFEST $( BOTTLES = 99 $) LET START() BE $( LET BEERS(N, S) BE $( TEST N = 0 THEN WRITEF("No more bottles") ELSE WRITEF("%N bottle%S", N, (N = 1) -> "", "s") WRITEF(" of beer%S", S) $) FOR I = BOTTLES TO 1 BY -1 DO $( BEERS(I, " on the wall, ") BEERS(I, ".*NTake one down, pass it around.*N") BEERS(I - 1, " on the wall.*N") $) FINISH $)
//language Concurrent Clean - lazy pure functional // Author: Jan Krynicky (jkry3025@comenius.mff.cuni.cz) module beer import StdEnv //run with console and no constructors (don't want to make windows, menu ...) Start = genbeer 99 where genbeer 0 = ["No more bottles of beer on the wall.\n", //We are all drunk enough. "No more bottles of beer.\n", //so sad! "Go to the store and buy some more.\n" //If you can fin it. : genbeer 99] //Go on, let's drink forever. genbeer n = [sn+++" Bottle(s) of beer on the wall, " +++ sn +++ " bottle(s) of beer.\n", "Take one down and pass it around.\n", toString(n-1)+++ " bottle(s) of beer on the wall." :genbeer (n-1)] where ns = toString(n) //end
(* Caml Light version of 99 bottles of beer *) (* Written by Bow-Yaw Wang (bywang@saul.cis.upenn.edu) *) let rec bottles = function 1 -> print_string "1 bottle of beer on the wall, 1 bottle of beer\n"; print_string "Take one down, pass it around,\n"; print_string "no more bottles of beer on the wall\n" | n -> print_int n; print_string " bottles of beer on the wall, "; print_int n; print_string " bottles of beer\n"; print_string "Take one down and pass it around,\n"; print_int (n-1); print_string " bottles of beer on the wall\n"; bottles (n-1) in bottles 99;;
% 99 bottles of beer in CLU by dcurtis@lcs.mit.edu start_up = proc() po: stream := stream$primary_output() for i: int in int$from_to_by(99, 1, -1) do if i = 1 then stream$putl(po, int$unparse(i) || " bottle of beer on the wall") stream$putl(po, int$unparse(i) || " bottle of beer...") else stream$putl(po, int$unparse(i) || " bottles of beer on the wall") stream$putl(po, int$unparse(i) || " bottles of beer...") end stream$putl(po, "Take one down, pass it around...") end stream$putl(po, "\nTime to get more beer!") end start_up
;Written by Bill Ensinger (Bill222E@aol.com) on Saturday February 24, 1996 ;8:00 - 9:41 pm Eastern Standard time at Taylor University. ;All praise to God; note that we just pass the beer, but don't drink! (deftemplate beer (field ninetynine)) (deffacts bottles (beer (ninetynine 99))) (defrule Bottlesninetynine "" (beer (ninetynine ?bottlenum)) ?fl <- (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." 0070 bottles(x#-1, FALSE) 0080 ENDFOR num 0090 0100 END 0110 0120 PROC bottles(num#, wall) CLOSED 0130 PRINT num#; 0140 0150 text$ := "bottle" 0160 0170 IF num# <> 1 THEN 0180 text$ := text$ + "s" 0190 ENDIF 0200 0210 PRINT text$," of beer"; 0220 0230 IF wall = TRUE 0240 PRINT "on the wall"; 0250 ENDIF 0260 0270 PRINT "." 0280 ENDPROC bottles
#!/bin/bash # Bourne Again shell version of 99 Bottles # Dave Plonka - plonka@carroll1.cc.edu typeset -i n=99 typeset bottles=bottles typeset no while [ 0 != $[ n ] ] do echo "${n?} ${bottles?} of beer on the wall," echo "${n?} ${bottles?} of beer," echo "take one down, pass it around," n=n-1 case ${n?} in 0) no=no bottles=${bottles%s}s ;; 1) bottles=${bottles%s} ;; esac echo "${no:-${n}} ${bottles?} of beer on the wall." echo done exit
#!/usr/bin/bs # bs version of 99 Bottles # Dave Plonka - plonka@carroll1.cc.edu # Thu Aug 8 1996 fun sing(n, end) s s = ("s", "")[ match(n, "^1$") ] put = format(format(format("%s bottle%%s of beer%%%%s", n), s), end) nuf for n = 99, n, put = "" sing(format("%-0.0f", n), " on the wall,") sing(format("%-0.0f", n), ",") put = "take one down, pass it around," --n sing((format("%-0.0f", n), "no")[ 0 == n ], " on the wall.") next run exit
PGM /* 99 Bottles of Beer in AS/400 CL (Command Language) */ /* Programmer: Werner Grzemba, 101326.3300@compuserve.com */ /* To avoid the necessity of any user action, the output is */ /* sent to the status line (except of the buy-request at end) */ DCL 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 SPARROWHAWK@WORLDNET.ATT.NET PROC 0 SET BEER=99 A: WRITE &BEER BOTTLES OF BEER ON THE WALL WRITE &BEER BOTTLES OF BEER WRITE TAKE ONE DOWN AND PASS IT AROUND SET BEER=&EVAL(&BEER-1) IF &BEER ,= 0 THEN GOTO A WRITE NO MORE BOTTLES OF BEER ON THE WALL WRITE NO MORE BOTTLES OF BEER
/* 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 (whitey@netcom.com) - 10/13/96" IN author HOW TO RETURN verse n: SELECT: n = 0: PUT "no more bottles of beer" IN s n = 1: PUT "1 bottle of beer" IN s ELSE: PUT "`n` bottles of beer" IN s RETURN s HOW TO DRINK: PUT 99 IN num WHILE num > 0: WRITE verse 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, brender@zko.dec.com ! begin forward routine BOTTLES : novalue, ! Main routine BOTTLE_S : novalue, ! 'bottle<s>' BOTTLE_COUNT : novalue; ! <n> or 'no' 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_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, brender@zko.dec.com ! begin external routine printf : novalue external_name('DECC$GXPRINTF'); ! ! To "port" this program to UNIX or WNT, use ! external_name('printf') or the appropriate lower case ! compilation option instead of the above. macro PUT_TEXT(T) = printf(uplit(%asciz '%s'), uplit(%asciz T)) %, PUT_NL (dummy) = printf(uplit(%asciz %string(%char(10)))) %; compiletime TEMP = 0; ! In principle, the complete text can be constructed at compile-time and ! output with a single PUT_TEXT call, however, that runs up against a ! compile-time maximum string length. This implementation constructs a ! complete stanza at compile-time. ! macro BOTTLE_S(COUNT) = %if COUNT eql 1 %then 'bottle' %else 'bottles' %fi %, BOTTLE_COUNT(COUNT) = %assign(TEMP, COUNT) %if TEMP eql 0 %then 'No' %else %string(%number(TEMP)) %fi %, BOTTLE_STANZA(COUNT) = PUT_TEXT(%string( BOTTLE_COUNT(COUNT), ' ', BOTTLE_S(COUNT), ' of beer on the wall; ', BOTTLE_COUNT(COUNT), ' ', BOTTLE_S(COUNT), ' of beer', %char(10), 'Take one down and pass it around', %char(10), BOTTLE_COUNT(COUNT-1), ' ', BOTTLE_S(COUNT-1), ' of beer on the wall', %char(10), %char(10))) %, BOTTLE_TEXT(COUNT)[] = BOTTLE_STANZA(COUNT); %if COUNT gtr 1 %then BOTTLE_TEXT(COUNT - 1) %fi %; global routine BOTTLES : novalue = begin ! Title ! PUT_NL(); PUT_TEXT(' "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.. */ GRANT String, nul, OutS, OutL, OutC, OutI; NEWMODE String = STRUCT(CASE OF :s9 CHAR(9), :s11 CHAR(11), :s13 CHAR(13), :s16 CHAR(16), :s31 CHAR(31) ESAC ); SYN nul = C'00'; OutS: PROC(s String LOC); END OutS; OutL: PROC(); END OutL; OutC: PROC(c CHAR); END OutC; OutI: PROC(i INT); END OutI; END io; beer: MODULE /* jr_31jan97 */ SEIZE String, nul, OutC, OutS, OutI, OutL <> USING io; bottles: PROC(n INT, wall BOOL, end CHAR); DCL s String; IF n>1 THEN OutI(n); s.s9:=' Bottles'//nul; ELSIF n=1 THEN s.s11:='one Bottle'//nul; ELSIF n=0 THEN s.s16:='no more Bottles'//nul; FI; OutS(s); s.s9:=' of Beer'//nul; OutS(s); IF wall THEN s.s13:=' on the Wall'//nul; OutS(s); FI; OutC(end); OutL(); END bottles; singTheSong: PROC(); DCL i INT, s String; DO FOR i:=99 DOWN TO 1; bottles(i, TRUE, ','); bottles(i, FALSE, '.'); s.s31:='Take one down, pass it around,'//nul; OutS(s); OutL(); bottles(i-1, TRUE, '.'); OD; END singTheSong; END beer;
\ Abundance 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 (vincec@microsoft.com) --> <% 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 lagrasta@zimage.com 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). NOTE./K9 BOTTLES OF BEER ON THE WALL NOTE./K9 BOTTLES OF BEER NOTE./TAKE ONE DOWN, AND PASS IT AROUND/ REVERT,NOLIST.
----- begin beer.bf ----- v v0\1:\1:\0\0\!:p15-< Bottles of Beer for Befunge 0 \ {befunge} >" ekaT">v written by Brian Raiter, 5/97 0>>.0"llaw eht no "v<#,: breadbox@muppetlabs.com "\, >"eno"^>0 #"^1^_v c1,>51g#^_"ti"^. >vr : $ "::^" down, pass "^|\*25,<^ # i e ^g1< ,>052*":dnuor t"vbv:< v0_^ . , ^< " " >52*".ll"v >,^ fb e v "aw eht no r"v """ ,: >" ;"^ f ^<@ meo >^"bottle"< "o $ o m^"re:" 52*^>"s"^v"les"<,: "^< ^"99 bott"< >^>^< >" yub ,erots eht ot oG"^ ------ end beer.bf ------
>9999*++000s1100sXv< >#v100g5-v X >100g3- |v _@ |-2g001_ v v *39s1010pg000 s0012-#< < vv*35s1010pg000< 1 v## *47s1011s0014g# < v*35s10103100sv 0 ^ < 1 ^ { 000 > x v s100+1g100 < >001g101g9gp001g201g -| s 0 1 0 0 0 2 xv# < 1 ^ >000v s v0pg< P 0 x g ^_5100s^ { 100 bottles of beer. { 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 tauman@earthlink.net ---> <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 cunniff@fc.hp.com } 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 (oliver@traverse.com) ;;;; 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 (wieger1@noord.bart.nl) */ 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 * wieger1@noord.bart.nl <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.") )
; PART1.CAL ; replace this (and the other PART?.CAL files) with: ; (do ; NIL ; ) ; if you want it to not make sounds. (do (sendMIDI -1 1 NOTE 48 64) (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0) (sendMIDI -1 1 NOTE 48 0) (delay 100) (sendMIDI -1 1 NOTE 43 64) (sendMIDI -1 1 NOTE 55 64) (delay 300) (sendMIDI -1 1 NOTE 55 0) (delay 100) (sendMIDI -1 1 NOTE 55 64) (delay 300) (sendMIDI -1 1 NOTE 55 0) (delay 100) (sendMIDI -1 1 NOTE 55 64) (delay 300) (sendMIDI -1 1 NOTE 55 0) (sendMIDI -1 1 NOTE 43 0) (delay 100) (sendMIDI -1 1 NOTE 48 64) (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 600) (sendMIDI -1 1 NOTE 60 0) (sendMIDI -1 1 NOTE 48 0) )-- PART2.CAL --
(do (sendMIDI -1 1 NOTE 50 64) (sendMIDI -1 1 NOTE 62 64) (delay 300) (sendMIDI -1 1 NOTE 62 0) (delay 100) (sendMIDI -1 1 NOTE 62 64) (delay 300) (sendMIDI -1 1 NOTE 62 0) (delay 100) (sendMIDI -1 1 NOTE 62 64) (delay 300) (sendMIDI -1 1 NOTE 62 0) (sendMIDI -1 1 NOTE 50 0) (delay 100) (sendMIDI -1 1 NOTE 45 64) (sendMIDI -1 1 NOTE 57 64) (delay 300) (sendMIDI -1 1 NOTE 57 0) (delay 100) (sendMIDI -1 1 NOTE 57 64) (delay 300) (sendMIDI -1 1 NOTE 57 0) (delay 100) (sendMIDI -1 1 NOTE 57 64) (delay 300) (sendMIDI -1 1 NOTE 57 0) (sendMIDI -1 1 NOTE 45 0) (delay 100) (sendMIDI -1 1 NOTE 50 64) (sendMIDI -1 1 NOTE 62 64) (delay 1200) (sendMIDI -1 1 NOTE 62 0) (sendMIDI -1 1 NOTE 50 0) )-- PART3.CAL --
(do (sendMIDI -1 1 NOTE 43 64) (sendMIDI -1 1 NOTE 59 64) (delay 400) (sendMIDI -1 1 NOTE 59 0) (delay 300) (sendMIDI -1 1 NOTE 59 64) (delay 300) (sendMIDI -1 1 NOTE 59 0) (delay 100) (sendMIDI -1 1 NOTE 59 64) (delay 600) (sendMIDI -1 1 NOTE 59 0) (delay 400) (sendMIDI -1 1 NOTE 59 64) (delay 250) (sendMIDI -1 1 NOTE 59 0) (delay 100) (sendMIDI -1 1 NOTE 59 64) (delay 250) (sendMIDI -1 1 NOTE 59 0) (delay 100) (sendMIDI -1 1 NOTE 59 64) (delay 250) (sendMIDI -1 1 NOTE 59 0) (delay 100) (sendMIDI -1 1 NOTE 59 64) (delay 500) (sendMIDI -1 1 NOTE 59 0) (sendMIDI -1 1 NOTE 43 0) )-- PART4.CAL --
(do (sendMIDI -1 1 NOTE 43 64) (sendMIDI -1 1 NOTE 55 64) (delay 400) (sendMIDI -1 1 NOTE 55 0) (delay 300) (sendMIDI -1 1 NOTE 55 64) (delay 300) (sendMIDI -1 1 NOTE 55 0) (delay 100) (sendMIDI -1 1 NOTE 57 64) (delay 600) (sendMIDI -1 1 NOTE 57 0) (delay 100) (sendMIDI -1 1 NOTE 59 64) (delay 250) (sendMIDI -1 1 NOTE 59 0) (sendMIDI -1 1 NOTE 43 0) (delay 100) (sendMIDI -1 1 NOTE 36 64) (sendMIDI -1 1 NOTE 60 64) (delay 250) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 250) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 250) (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 500) (sendMIDI -1 1 NOTE 60 0) (sendMIDI -1 1 NOTE 36 0) )
COMMENT 99 BOTTLES IN CUPL (CORNELL UNIVERSITY PROGRAMMING LANGUAGE, C. 1966) COMMENT DAVE PLONKA - PLONKA@DOIT.WISC.EDU COMMENT FEB 17 1998 LET N = 99 PERFORM SONG WHILE N GT 2 LINES BLOCK WRITE /N, ' BOTTLES OF BEER ON THE WALL,' WRITE /N, ' BOTTLES OF BEER,' LINES END LINE BLOCK WRITE 'TAKE ONE DOWN, PASS IT AROUND,' LINE END SONG BLOCK PERFORM LINES PERFORM LINE LET N = N - 1 WRITE /N, ' BOTTLES OF BEER ON THE WALL.' 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 {? A write annotation bottles }{ A write annotation bottle } A write annotation of beer, A write new line A write annotation Take one down and pass it around, A write new line . 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 annotation bottles }{ A write annotation bottle } A write annotation of beer on the wall. 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