99 Bottles of Beer
One program in 571 languages
 
     
  Submit new example     Change log     History     Links     Tip: internet.ls-la.net     Thanks, Oliver     Guestbook      
Choose languages starting with letter:
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
S Plus   SAIL   SAOL   SAS   Sather   Saul   ScalaScript   Scheme   ScriptBasic   ScriptEase   sed   Self   Sendmail   SETL   Sharp EL9000 Calculator   SheerPower   ShowText   Silk   SIMPLE   Simscript   Simula   Sisal   Slick C   SmallBasic   SmallTalk   SML   Snobol   sorta   Spaghetti   Spitbol   Spoon   SPSS   SQL   SR   StarBasic   StarLogo   Stata   Superbase   SuperTalk   Surf   Sybase SQL   System 1032  
 
  Programming language: S Plus
 
Using S-Plus code
 
for(i in 100:1){
            if(i>1){
                        cat(i,"bottles of beer on the wall,",i,"bottles of beer\n")
                        cat("Take one down, pass it around\n")
                        cat(i-1,"bottles of beer on the wall\n",fill=TRUE)
            }
            else{
                        cat(i,"bottle of beer on the wall,",i,"bottle of beer\n")
                        cat("Take one down and pass it around\n")
                        cat("No bottles of beer on the wall!!\n",fill=TRUE)
            }
}
 
  Programming language: SAIL
 
COMMENT
  "99 Bottles of Beer" in SAIL (popular on PDP-10s)
  William Soley <soley@sun.com> 14-May-2003
;

BEGIN "99BOB"

  REQUIRE "{}" DELIMITERS;
  DEFINE crlf = {('15&'12)};

  INTEGER n;
  FOR n _ 99 STEP -1 UNTIL 1 DO
    BEGIN "Loop"
      STRING bottles;
      bottles _ IF n > 1 THEN " bottles " ELSE " bottle ";
      PRINT(n, bottles, "of beer on the wall.", crlf);
      PRINT(n, bottles, "of beer,", crlf);
      PRINT("take one down, pass it around,", crlf);
    END "Loop";
  PRINT("no more bottles of beer on the wall.", crlf);

END "99BOB"
 
  Programming language: SAOL
 
SAOL is the music-synthesis language which is part of the MPEG-4 
standard.  There's a homepage for SAOL at http://sound.media.mit.edu

Orchestra (beer.saol) :

global {
  srate 1000; // sip rate
  krate 100;  // beer rate
}

instr beer() {
  ksig drink;

  drink = kline(99,1,1);

  if (drink == 0) {
    kdump("No bottles of beer on the wall.");
    kdump("Everybody's drunk!");
    turnoff;
    }

  else {
    if (drink == 1) {
      kdump(drink," bottle of beer on the wall.");
      kdump(drink," bottle of beer.");
    } 
    else { 
      kdump(drink," bottles of beer on the wall.");
      kdump(drink," bottles of beer.");
    }
    kdump("Take one down, pass it around,");

    if (drink-1 == 1) {
      kdump(drink-1," bottle of beer on the wall.");
    } 
    else { 
      kdump(drink-1," bottles of beer on the wall.");
    }
    kdump();
  }
}

------------

Score (beer.sasl) :

0 beer 1
 
  Programming language: SAS
 
/* SAS version of 99 bottles of beer        */
/* by Whitey (whitey@netcom.com) - 06/05/95 */

data _null_;
   do i = 99 to 1 by -1;
      put i 'bottles of beer on the wall,' i 'bottles of beer,';
      put 'take one down, pass it around,';
      j = i - 1;
      if j = 0 then
         put 'no more ' @;
      else
         put j @;
      put 'bottles of beer on the wall.';
   end;
run;
 
  Programming language: Sather
 
<a href=http://www.icsi.berkeley.edu/Sather>Click</a> for information.

-- Sather for 99 Bottles of Beer
--
-- David Stoutamire (davids@icsi.berkeley.edu)

class MAIN is
   main is
      loop
         b::=99.downto!(1);
         #OUT + bob(b) + " on the wall, "
              + bob(b) + ".\n"
              + "Take one down, pass it around, "
              + bob(b-1) + " on the wall.\n\n";
      end
   end;

   bob(i:INT):STR is
      case i
      when 0 then return "no more bottles of beer";
      when 1 then return "1 bottle of beer";
      else return i.str + " bottles of beer";
      end
   end
end
 
  Programming language: Saul
 
Home-brew language.  See 
http://keaggy.intmed.mcw.edu/saul.html for details

;
; 99 Bottles of Beer in SAUL
;    (http://keaggy.intmed.mcw.edu/saul.html)
;
; RTK, rkneusel@post.its.mcw.edu, 10-Apr-97
;

       fixn(0)
       setn(n,99)
:loop, putn(n)
       disp(` bottles of beer on the wall, `)
       putn(n)
       disp(` bottles of beer.`)
       putc(13)
       disp(`Take one down, pass it around, `)
       subt(n,1,m)
       putn(m)
       comp(m,1)
       brne(:here)
       disp(` bottle of beer on the wall.`)
       jump(:there) 
:here, disp(` bottles of beer on the wall.`)
:there,putc(13)
       putc(13)
       comp(n,2)
       breq(:last)
       subt(n,1,n)
       jump(:loop)
:last, disp(`1 bottle of beer on the wall, 1 bottle of beer.`)
       putc(13)
       disp(`Take one down, pass it around, `)
       disp(`no more bottles of beer on the wall.`)  
       endp
 
  Programming language: ScalaScript
 
!ScalaScript

/* 99 bottles of beer (99bottles.sca)                                    */
/* written in ScalaScript for Scala InfoChannel Designer (www.scala.com) */
/* (c) 2002 Ulrich Peters                                                */
/* http://www.oktrier.de/                                                */

EVENT
  Group:
    Integer(i);
    BackgroundSettings(Size(640, 480));
    Config.SaveOpts(SaveEditable(On));
  Sequence:
    i = 100;
    :"loop"
    i = i - 1;
    EVENT
      Group:
        Display(Backdrop(Pen(16)), Margin(10, 10, 0, 0), Tabs(Explicit(80, 160, 240, 320, 400, 480, 560)),
         UserPalette(RGBPen(1, $0, $ffffff, $999999, $555555, $712068, $df449c, $dc110e, $662200, $ff5a00,
         $ff9c00, $ffee00, $8800, $dd00, $cccc, $66ff, $aa, $777777, $bbbbbb, $dddddd)));
        Text(20, 20, "!(i) Bottle(s) of beer on the wall, !(i) bottle(s) of beer", AntiAlias(On),
         Update(Normal), Font("FranklinGotTReg (Western [])", 50), Wrap(On, Auto(610)));
    END
    EVENT
      Group:
        Display(Backdrop(Pen(16)), Margin(10, 10, 0, 0), Tabs(Explicit(80, 160, 240, 320, 400, 480, 560)),
         UserPalette(RGBPen(1, $0, $ffffff, $999999, $555555, $712068, $df449c, $dc110e, $662200, $ff5a00,
         $ff9c00, $ffee00, $8800, $dd00, $cccc, $66ff, $aa, $777777, $bbbbbb, $dddddd)));
        Text(20, 20, "Take one down and pass it around,", AntiAlias(On), Update(Normal),
         Font("FranklinGotTReg (Western [])", 50), Wrap(On, Auto(610)));
    END
    EVENT
      Group:
        Display(Backdrop(Pen(16)), Margin(10, 10, 0, 0), Tabs(Explicit(80, 160, 240, 320, 400, 480, 560)),
         UserPalette(RGBPen(1, $0, $ffffff, $999999, $555555, $712068, $df449c, $dc110e, $662200, $ff5a00,
         $ff9c00, $ffee00, $8800, $dd00, $cccc, $66ff, $aa, $777777, $bbbbbb, $dddddd)));
        Text(20, 20, "!(i-1) bottle(s) of beer on the wall", AntiAlias(On), Update(Normal),
         Font("FranklinGotTReg (Western [])", 50), Wrap(On, Auto(610)));
    END
    EVENT
      Group:
        If(i > 1);
        Goto("loop", Bookmark(Off));
    END
    Quit(1);
END
 
  Programming language: Scheme
 
;;; Tim Goodwin (tim@pipex.net)

(define bottles
  (lambda (n)
    (cond ((= n 0) (display "No more bottles"))
          ((= n 1) (display "One bottle"))
          (else (display n) (display " bottles")))
    (display " of beer")))

(define beer
  (lambda (n)
    (if (> n 0)
        (begin
          (bottles n) (display " on the wall") (newline)
          (bottles n) (newline)
          (display "Take one down, pass it around") (newline)
          (bottles (- n 1)) (display " on the wall") (newline)
          (newline)
          (beer (- n 1))))))

(beer 99)
 
  Programming language: ScriptBasic
 
' ScriptBasic version of 99 Bottles of beer (Bottles.bas)
' See http://script.basic.hu/html/index.html
' Philipp Winterberg, http://www.winterbergs.de

a$ = " \98\111\116\116\108\101\40\115\41\32\111\102\32\98\101\101\114"
c$ = " \111\110\32\116\104\101\32\119\97\108\108\99\32\32\8\8\8\8\108"
for b = 99 to 1 step -1
  print "\13\10",b,a$,c$,"\44\n",b,a$,"\46\n\84\97\107\101\32\111\110"
  print "\101\32\100\111\119\110", ",\32\112\97\115\115\32\105\116\32"
  print "\97\114\111\117\110\100\44\13\10",(b-1),a$,c$,"\46\32 \13\10" 
next b
end
 
  Programming language: ScriptEase
 
// ScriptEase version of 99 Bottles of beer (Bottles.jsa)
// See http://www.sedesk.com/us/desktop/
// Philipp Winterberg, http://www.winterbergs.de

#include <inout.jsh>

a = " bottle(s) of beer"; 
c = " on the wall"; 
d = "Take one down, pass it around,";

for (b = 99 ; b > 0 ; b--) 
  Clib.printf("%d%s%s,\n%d%s.\n%s\n%d%s%s.\n\n", b, a, c, b, a, d, (b - 1), a, c);

PauseForWin(''); 
Clib.exit(EXIT_SUCCESS);
 
  Programming language: sed
 
The UNIX stream editor.  The creator of sed didn't think it's 
interesting to edit empty files, so this needs some kind of input, e.g. 

echo '' | sed -f 99.sed

1{
        s/.*/99 bottles of beer on the wall/
        h
        : x
        p
        s/ on.*//
        p
        s/.*/take :&: down, pass it around/
        /one/{
                s/:.*:/it/
                p
                g
                s/on\(.*le\)/no mor\1s/
                p
                s/.*//
                q
        }
        s/:.*:/one/
        p
        g
        y/1234567890/0123456789/
        /^.[0-8] /{
                s/^.//
                x
                s/\(.\).*/\1/
                G
                s/\n//
        }
        s/^0//
        s/^1\( .*le\)s/one\1/
        h
        p
        s/.*//
        p
        g
        b x
}
 
  Programming language: Self
 
"99 Bottles of Beer in Self
 (http://research.com.sun/self/)
 by David Eddyshaw, david@jeddyshaw.freeserve.co.uk
"
traits integer _AddSlots: (|
  bottles = ((= 0
              ifTrue: ['No more bottles']
               False: [= 1
                       ifTrue: ['1 bottle']
                        False: [asString, ' bottles']]),
              ' of beer')
|).
99 downTo: 1 Do: [
 | :n |
 (n bottles, ' on the wall;\n',
  n bottles, '.\nTake one down; pass it around:\n',
  (n - 1) bottles, ' on the wall.\n\n') print.
].
 
  Programming language: Sendmail
 
Sendmail is used by mail systems for routing and controlling e-mail delivery.  
It was never really intended for general purpose programming, but here you go.

# Save this to /tmp/foo.bar
# echo '49 9 9' | /usr/lib/sendmail -bt -d21 -C/tmp/foo.bar
# Sorry, Smail is too brain dead to run this.  Use sendmail instead.
# Programmed by: Felix von Leitner <leitner@inf.fu-berlin.de>

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

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

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

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

S49
R$- $-					$>48 $1 $2
 
  Programming language: SETL
 
An online <a href=http://galt.nyu.edu/~bacon/setl-server.html>SETL server</a> 
is available where you can run the program without the compiler.

$ SETL version
$ written by Arion Lei (philipl@cs.ust.hk)
beer := {1,2..99};
(until beer={})
  print(#beer, " bottles of beer on the wall,");
  print(#beer, " bottles of beer.  Take one down, pass it around,");
  $ take an arbitrary one down
  beer less := arb beer;
  if beer/={} then
    print(#beer, " bottles of beer on the wall.");
  end if beer/={};
end until;
print("No more bottles of beer on the wall, no more bottles of beer.");
print("Go to the store and buy some more... 99 bottles of beer");
 
  Programming language: Sharp EL9000 Calculator
 
Syntactic conventions:
  ASCII   Sharp
  -----   -----
     \>   begin-loop
     <\   end-loop
     _n   subroutine n
     \\   end-of-program
 *Y->[]   conditionals
 *N->[]   
     __   space character

------- cut ----------
Title: 99 bottles of beer, by S Keppel-Jones
 M:beer=99\>beer>1*Y->[_1]beer>1*N->[_4]_2beer>1*Y->
   [_1]beer>1*N->[_4]_3beer=beer-1__beer>0*N->[_5_2\\]
   beer>1*Y->[_1]beer>1*N->[_4]_2<\
_1:beer=beer,bottles=0,of=0,beer=beer,
_2:on=0,the=0,wall=0,
_3:take=0,one=0,down=0,pass=0,it=0,around=0,
_4:one=0,bottle=0,of=0,beer=beer,
_5:no=0,more=0,bottles=0,of=0,beer=0,
-------- cut ---------
 
  Programming language: SheerPower
 
// SheerPower version of 99 Bottles of beer (Bottles.spsrc)
// See http://nkserver.ttinet.com/sheerpower/
// Philipp Winterberg, http://www.winterbergs.de

clear
declare string a, c
declare integer b 
a=" bottle(s) of beer" 
c=" on the wall"

for b=99 to 1 step -1
  print b; a; c; ","
  print b; a; "."
  print bold:"Take one down, pass it around,"
  print b-1; a; c; "."
  print
next b
 
  Programming language: ShowText
 
' ShowText version of 99 Bottles of beer (Bottles.st)
' http://www.programmersheaven.com/zone22/cat254/2672.htm
' Philipp Winterberg, http://www.winterbergs.de
'
INTKEYS CLEAR OFF\RST KEYCLK\NOCHK\CSR OFF\MOUSE OFF
COLOR 15,0\CLS\P+\P@ 25,1
%B=99
WHILE %B>0
PRINT %B,2Z;\PRINT " bottle(s) of beer on the wall,"
PRINT %B,2Z;\PRINT " bottle(s) of beer."
PRINT "Take one down, pass it around,"
%B--\PRINT %B,2Z;\PRINT " bottle(s) of beer on the wall."
SCROLL UP (1,1,25,80)\WAIT 1
WEND
EXITC

 
  Programming language: Silk
 
Silk is a language for generating web pages on the fly.

<%sub default()%>
<html><title>SilkyBeers</title><body><h1>99 beers on the wall, silk style...</h1><br><br><br>
<%
	nBeers = 99
	while (nBeers > 0)
		?CStr(nBeers) & " bottles of beer on the wall,"
		?Cstr(nBeers) & " bottles of beer..."
		?"Take one down, pass it around,"
		nBeers = nBeers - 1
		?CStr(nBeers) & " bottles of beer on the wall.<br>"
	wend
%>
</body></html>
<%end sub%>
 
  Programming language: SIMPLE
 
%  SIMPLE version of 99 bottles of beer
%  Laurent Vogel,  http://lvogel.free.fr
%  SIMPLE at http://www.eleves.ens.fr:8080/home/madore/simple.tgz

<def|p|[<if|@1@|0|No more|@1@>] bottle[<if|@1@|1||s>] of beer><def|r|
><def|i|99><def|loop|[<p|<i>>]<def|w| on the wall><w>,<r>[<p|<i>>].
Take one down, pass it around,[<def|i|<-|<i>|1>>]<r>[<p|<i>>]<w>.
[<if|<i>|0||<r>[<loop>]>]><loop>
 
  Programming language: Simscript
 
SIMSCRIPT is a simulation language from CACI and runs on PCs and VAXen.

'' 99 Bottles of Beer using SIMSCRIPT
'' Author: Jeremy Konopka  <konopka@cs.uregina.ca>

PREAMBLE
        PROCESSES
                INCLUDE brewer, drinker
        RESOURCES
                INCLUDE bottle
        DEFINE countem AS A INTEGER VARIABLE

END

MAIN
        CREATE EVERY bottle(1)
        LET U.bottle(1) = 1
        LET countem=100
        ACTIVATE A brewer NOW
        START SIMULATION
        PRINT 1 LINE THUS
           No more bottles of beer on the wall.

END

PROCESS brewer
        FOR I=1 TO 99
        DO
                ACTIVATE A drinker NOW
        LOOP
END

PROCESS drinker

        REQUEST 1 bottle(1)
        RELINQUISH 1 bottle(1)
        LET countem = countem - 1

        IF countem > 1 
        PRINT 3 LINES WITH countem, countem THUS
          ** bottles of beer on the wall.
          ** bottles of beeeeer ...,
          Take one down, pass it around,
        ELSE
        PRINT 3 LINES WITH countem, countem THUS
          ** bottle of beer on the wall.
          ** bottle of beeeeer ...,
          Take it down, pass it around,
        ALWAYS
        IF countem > 2 
        PRINT 2 LINES WITH countem-1 THUS
          ** bottles of beer on the wall.

        ALWAYS
        IF countem = 2 
        PRINT 2 LINES THUS
          One more bottle of beer on the wall.

        ALWAYS
END
 
  Programming language: Simula
 
BEGIN
  COMMENT
     Simula version of 99 beers
     Maciej Macowicz (mm@cpe.ipl.fr)
     Status: UNTESTED :)
  ;
  INTEGER bottles;

  FOR bottles:= 99 STEP -1 UNTIL 1 DO 
  BEGIN
    OutInt(bottles,1);
    OutText("bottle(s) of beer on the wall, ");
    OutInt(bottles,1);
    Outtext("bottle(s) of beer");
    OutImage;
    Outtext("Take one down, pass it around, ");
    OutInt(bottles,1);
    OutText("bottle(s) of beer on the wall, ");
  END;
  OutText("1 bottle of beer on the wall, one bottle of beer."); 
  Outimage;
  OutText("Take one down, pass it around, no more bottles of beer on the wall");
  OutImage
END    
 
  Programming language: Sisal
 
% ------------------------------------------------------------
% The classic N bottles of beer problem.  The Sisal language
% is implicitly parallel and functional.  It is not really desigined
% for string processing (scientific numeric stuff is more like it!)
% The following program will run in parallel on Crays, the
% SGI Challenge, the Meiko, etc....  and run just swell on
% your average ordinary PC too.  More information on the Sisal
% language project can be found at
% 
% http://www.llnl.gov/sisal/SisalHomePage.html
%
% or contact sisal-info@sisal.llnl.gov
%
% Author: Pat Miller (patmiller@llnl.gov)
% 
% ------------------------------------------------------------

define main

type string = array[character];

% ------------------------------------------------------------
% OUCH -- have to really start from scratch
% ------------------------------------------------------------
function DigitToChar(d : integer returns character)
  character(integer('0')+d)
end function

% ------------------------------------------------------------
% Sisal has no I/O runtime library for strings so we
% can build up the ASCII representation a digit at a time
% The sign handling is there for completeness and is not needed
% to do the BEER problem
% ------------------------------------------------------------
function itoa(n : integer returns string)
  array_setl(
  let
    s := for initial
	   x := abs(n);
	   d := array[1: DigitToChar( mod(x,10) )];
         while x > 10 repeat
	   x := old x / 10;
	   d := array_addl(old d,DigitToChar(mod(x,10)));
	 returns
	   value of d
	 end for
  in
    if n < 0 then array_addl(s,'-') else s end if
  end let
  ,1)
end function

% ------------------------------------------------------------
% Produce one stanza of the 99 bottles of beer song.  Some care
% is taken to keep it grammatical
% ------------------------------------------------------------
function BottlesOfBeer(i : integer returns array[string])
  let
    s,bottles,preface,n,nextbottles :=
      if i = 1 then
	"1"," bottle","If that bottle","No more"," bottles"
      elseif i = 2 then
	itoa(2)," bottles","If one of those bottles",itoa(1)," bottle"
      else
	itoa(i)," bottles","If one of those bottles",itoa(i-1)," bottles"
      end if;
  in
    array[1:
      s || bottles || " of beer on the wall", 
      s || bottles || " of beer!",
      preface || " should happen to fall... ",
      n || nextbottles || " of beer on the wall!",
      ""
    ]
  end let
end function
  

% ------------------------------------------------------------
% This main loop executes in parallel stuffing the 4 lines
% of each stanza into an array holding the whole song
% ------------------------------------------------------------
function main(n : integer returns array[string])
  for i in 0,n-1
    howmany := n-i;
    stanza := BottlesOfBeer(howmany);
  returns value of catenate stanza
  end for ||
  array[1: "Time to buy more beer"]
end function
 
  Programming language: Slick C
 
/* 99 Bottles of Beer in Slick-C
-- Slick-C is the programming language of
-- Visual Slickedit from Slickedit Inc.
-- More on http://www.slickedit.com
-- programmed by: Siegfried Hirsch, http://www.hhs.de
-- This is a new command for the editor which must
-- be loaded with the "load" command
-- Then it could be used to insert the song into
-- the current editor window with an argument of
-- the number of bottles you would like to drink.
-- CommandLine: bottles 99 <return>
*/
_command bottles(...) {
   param = arg(1);
   if (param=="" || ! isinteger(param)) {
       message('Please give number of bottles');
       return(1);
   }
   for (i = param; i > 0; i--) {
      insert_line(i ' Bottles of beer on the wall,' );
      insert_line(i ' Bottles of beer.');
      insert_line( "Take one down, pass it around,");
      if (i - 1 == 0) {
         insert_line ("Go to the store and buy some more.");
      } else {
         insert_line(i-1 " bottles of beer on the wall.");
      }
      insert_line("");
   }
}
 
  Programming language: SmallBasic
 
# SmallBasic version of 99 Bottles of beer (Bottles.bas)
# See http://smallbasic.sourceforge.net/
# Philipp Winterberg, http://www.winterbergs.de

a=" bottle(s) of beer":c=" on the wall":cls
for b=99 to 1 step -1
  ?b;a+c+",":?b;a+".":?"Take one down, pass it around,":?b-1;a+c+".":?
next
 
  Programming language: SmallTalk
 
"Programmer: patrick m. ryan - pryan@access.digex.net
"http://www.access.digex.net/~pryan

99 to: 1 by: -1 do: [ :i |
	i print. ' bottles of beer on the wall, ' print.
	i print. ' bottles of beer. ' print.
	'take one down, pass it around, ' print.
	(i-1) print. ' bottles of beer on the wall, ' print.
]
 
  Programming language: SML
 
(* SML version of 99 bottles of beer *)
(* written by Norvald - norvald@hsr.no *)
let
    val itoa = Makestring.intToStr
    fun getabeer 0 = (print "Go to the store and buy some more,\n";
		      print "99 bottles of beer on the wall.\n")
      | getabeer 1 = (print "1 bottle of beer on the wall,\n";
		      print "1 bottle of beer,\n";
		      print "Take one down, pass it around,\n";
		      print "0 bottle of beer on the wall.\n\n";
		      getabeer (0)) 
      | getabeer x = (print (itoa(x)^" bottles of beer on the wall,\n"); 
		      print (itoa(x)^" bottles of beer,\n");
		      print "Take one down, pass it around,\n";
		      print (itoa(x-1)^" bottles of beer on the wall.\n\n");
		      getabeer (x-1)) 
in
    getabeer 99;
end
 
  Programming language: Snobol
 
* 99 BOTTLES OF BEER IN SNOBOL (UNTESTED)
         BEER = 99
MOREBEER OUTPUT = BEER ' BOTTLES OF BEER ON THE WALL'
         OUTPUT = BEER ' BOTTLES OF BEER'
         OUTPUT = 'TAKE ONE DOWN, PASS IT AROUND'
         BEER = BEER - 1
         OUTPUT = BEER ' BOTTLES OF BEER ON THE WALL'
         GT(BEER,0)   : S(MOREBEER)
         OUTPUT = 'NO MORE BOTTLES OF BEER ON THE WALL'
         OUTPUT = 'NO MORE BOTTLES OF BEER'
         OUTPUT = 'GO TO THE STORE AND BUY SOME MORE'
         OUTPUT = '99 BOTTLES OF BEER'
END
 
  Programming language: sorta
 
[  sorta version of 99 bottles of beer     ]ld
[  Laurent Vogel,  http://lvogel.free.fr   ]ld

[" bottle"TD1_+=s" of beer"T$ld`ldD]:p[" on the wall"1STD]:w[""`ldD=a]:n
[","=w#=p"."#=p"Take one down, pass it around,"`ldd1_+DD"."=w#=p=n]:a99D
["s"T]:sD=a"."2D=w"No more"=p
 
  Programming language: Spaghetti
 
See http://www.azstarnet.com/~jeffryj/spaghett.txt

1[*=99]800              '99 Bottles of beer   N=99  
809[283~9:400]810       'xx Bottle(s) of beer on the wall
813[283~13:814]815      'xx Bottle(s) of beer
805[283~5:600]806       'Take one down and pass it around 
812[283~12:600]813      'xx Bottle(s) of beer on the wall
821[283=0]822           '100 200 300 400 500 600
804[283~4:500]805       '100 200 300 400 600
806[283~6:100]807       '700 600
818[283~17:500]819      '100 200 300 400 500 600 600
800[283~0:100]801       
814[*-1]100             'N=N-1
808[283~8:300]809
810[283~10:600]811
817[283~16:400]818
803[283~3:400]804       
820[283~19:600]821
822[*~0:0]800           'IF N=0 THEN END
807[283~7:200]808       
819[283~18:600]820
802[283~2:300]803       
816[283~15:300]817
811[283~11:700]812
801[283~1:200]802       
815[283~14:200]816
103[284-10]104
101[285=0]102           'B=0
104[285+1]102
105[284+48]106
109[?284]110            'PRINT CHR$(B);
102[284<10:105]103      'A=A MOD B:B=A\10
106[285+48]107
108[?285]109
107[285~48:109]108      'IF A<>48 PRINT CHR$(A);
100[284=*]101           'A=N
110[283+1]800
207[283+1]800
206[?101]207
205[?108]206
204[?116]205
203[?116]204
202[?111]203
201[?98]202
200[?32]201             '200 PRINT " bottle";
302[283+1]800
301[?115]302 
300[*~1:302]301         '300 IF N<>1 THEN PRINT "s";
400[?32]401             '400 PRINT " of beer";
402[?102]403
401[?111]402
404[?98]405
403[?32]404
406[?101]407
405[?101]406
408[283+1]800
407[?114]408
500[?32]501             '500 PRINT " on the wall";
503[?32]504
502[?110]503
505[?104]506
504[?116]505
506[?101]507 
508[?119]509
511[?108]512 
507[?32]508
509[?97]510
512[283+1]800
510[?108]511
501[?111]502
601[?10]602
600[?13]601             '600 PRINT
602[283+1]800
700[?84]701             '700 PRINT "Take one down, pass it around";
703[?101]704
706[?110]707
709[?100]710
712[?110]713 
715[?112]716
718[?115]719
721[?116]722
724[?114]725
727[?110]728
701[?97]702
704[?32]705
707[?101]708
710[?111]711
713[?44]714
716[?97]717
719[?32]720
722[?32]723
725[?111]726
728[?100]729
702[?107]703
705[?111]706
708[?32]709
711[?119]712
714[?32]715
717[?115]718
720[?105]721
723[?97]724 
726[?117]727
729[283+1]800
 
  Programming language: Spitbol
 
* MaxSPITBOL version (SPITBOL implementation on
* the Macintosh from Catspaw, Inc. (Salida, CO).
* NOTE:  I have no connection w/them other than being
* a long-time satisfied user of their product
* D.H.  <hedges@pilot.njin.net>

     p0 = "NO MORE" ;  p1 = " BOTTLE" ; p2 = "S" ; p3 = " OF BEER"
     p4 = " ON THE WALL" ; p5 = "TAKE ONE DOWN, PASS IT AROUND"

     b = 99
     p6 = ((NE(b,0) b, p0) p1 (NE(b,1) p2,) p3)
A1   OUTPUT = p6 p4 ; OUTPUT = p6 ; OUTPUT = p5
     b = b - 1
     p6 = ((NE(b,0) b, p0) p1 (NE(b,1) p2,) p3)
     OUTPUT = p6 p4 ; OUTPUT = ; NE(b,0)                   :S(A1)
END
 
  Programming language: Spoon
 
Taken from the example inside www.bluedust.com/pub/sources/spoon-v1.zip
See also: http://www.bluedust.com/spoon/

010111111111001000111111111111101000000110110010001000100000
001101000100000001101101100100010101010110110000011010010001
000110111010010000001101001001000100000001101101101111111111
101100100010010010101101100100010101000100000001101101100000
110100010001110100000011010001000110111111111111010010010101
100000110110110000110000011111111111010001000110000100000011
010010101000100011001000000011011011101001001000000110100010
000000111011011001000101010000011011000001101101101100100010
010101010110110110000011010010010001000110110111010010010000
001101000100011101000000110110110000010001000100000001101100
100000001100110100101011001000100010000000110110000011011111
111110010001111111101111111101001000000110100100100010001010
101011011000001101001000100011011101001000000110110010001101
101101101100101001001001001001000000110110110110110110110010
100100100010000000110100010000000111111001000111111111101000
000110110010100101111001000111111111101000000110111100101001
011111001000111111111110100000011011001010010011111110010100
010100000000000000000000000000010100000000000000000000000010
100100100010001001010101011011011000001101001001000100011011
011101001001000000110110010001101101101111111111111111001010
010010010010000001101101101101100100000001101011110010001111
111111010000001101100101001011111111100100011111111111010000
001101100000000101000000000000000000000000000000101001011111
110010001100000000000000000000000000000001000000110110010100
101111110010001111111111111010000001101100101011100101000101
011111111111110010100101111111100100011000000000000000000000
000000000010000001101100000000101001011111111100100011111111
111010000001101100000000101000000101001011111111001000110000
000000000000000000000000000100000011011110010100101111111100
100011111111111101000000110111111001010000000000000000000000
000000000000000001010000000000001010010111111100100011000000
000000000000000000000000010000001101110010100101111111100100
011111111111110100000011011000001010010110010001100000000000
000000000000000000000001000000110110010101111111111100101000
101001011111111100100011000000000000000000000000000000010000
001101100000000000000000101000000000000101001001001000100010
101010110110000011010010001000110111010010000001101100100011
011011011011001010010010010010010000001101101101101101101100
101001001001011110010001111111101000000110110000000010100101
111001000111111111101000000110111100101001011111001000111111
111110100000011011001010010011111110010100010100000000000000
000000000000010100000000000000000000000010100100100010001001
010101011011011000001101001001000100011011011101001001000000
110110010001101101101111111111111111001010010010010010000001
101101101101100100000001101011110010001111111111010000001101
100101001011111111100100011111111111010000001101100000000101
000000000000000000000000000000101001011111110010001100000000
000000000000000000000001000000110110010100101111110010001111
111111111010000001101100101011100101000101011111111111110010
100101111111111001000110000000000000000000000000000000100000
011011000001010000000000001010010111111100100011111111111101
000000110111111001010111111111111100101011111111110010100000
000000000000000010100101111111001000110000000000000000000000
000000000100000011011100101001011111111001000111111111111010
000001101100000101000000101000000000000000000000000000000101
001011111110010001100000000000000000000000000000001000000110
111001010010111111100100011111111111101000000110110000000010
101111111111100101011111111001010000000000000000000000000000
001010010111111110010001100000000000000000000000000000001000
000110111100101001011111001000111111111111111010000001101100
101011111111111110010100000000000000000000000000000000010100
101111111001000110000000000000000000000000000000100000011011
110010100101111111100100011111111111101000000110110010100101
110010001100000000000000001000000110110010100101110010001111
111101000000110110010100010100101111111110010001100000000000
000000000000000001000000110110000000010100101111111001000111
111111111010000001101111100101011111111111001010010111111110
010001100000000000000000000000000000000001000000110111111001
010010111110010001111111111111110100000011011001010010111001
000111111110100000011011000001010000000000001010111111001010
000000000000000000000001010000000000000000000000000000000001
010010111111110010001100000000000000000000000000000000001000
000110111001010000000000001010001000000011011011011000010001
000000011010001000000011011011001000101010101101100000110100
100010001101110100100000011010010010001000000011011011011111
111111011001000100100101011011001000101010001000000011011011
000001101000100011101000000110100010001101111111111110100100
101011000001101101100001100000111111111110100010001100001000
000110100101010001000110010000000110110111010010010000001101
000100000001110110110010001010100000110110000011011011011001
000100101010101101101100000110100100100010001101101110100100
100000011011010010001000111010000001101101100000100010001000
000011011001000000011001101001010110010001000100000001101100
000110111111111100100011111111011111111010010000001101001001
000100010101010110110000011010010001000110111010010000001101
100100011011011011011001010010010010010010000001101101101101
101101100101001001000100000001101000100000001111110010001111
111111010000001101100101001011110010001111111111010000001101
111001010010111110010001111111111101000000110110010100100111
111100101000101000000000000000000000000000101000000000000000
000000000101001001000100010010101010110110110000011010010010
001000110110111010010010000001101100100011011011011111111111
111110010100100100100100000011011011011011001000000011010111
100100011111111110100000011011001010010111111111001000111111
111110100000011011000000001010000000000000000000000000000001
010010111111100100011000000000000000000000000000000010000001
101100101001011111100100011111111111110100000011011001010111
001010001010111111111111100101001011111111001000110000000000
000000000000000000000100000011011000000001010010111111111001
000111111111110100000011011000000001010000001010010111111110
010001100000000000000000000000000000001000000110111100101001
011111111001000111111111111010000001101111110010100000000000
000000000000000000000000000010100000000000010100101111111001
000110000000000000000000000000000000100000011011100101001011
111111001000111111111111101000000110110000010100101100100011
000000000000000000000000000000000010000001101100101011111111
111001010001010010111111111001000110000000000000000000000000
000000100000011011000000000000000001010000000000001010111001
0100000000000010100010000000110110110110011
 
  Programming language: SPSS
 
****************************************************************************
* File:			beer.sps
* Source Code:	SPSS 5.0
* System/OS:		HP/UNIX
* Written By:		Keith Chidsey (keithc@gsbc.com)
*
* Write out lyrics to "99 Bottles of Beer on the Wall" to file <beersong>.
****************************************************************************

FILE HANDLE    	DUMMY/NAME'BEER.SPS'/LRECL=80
FILE HANDLE    	BEERSONG/NAME'BEERSONG'/LRECL=80

DATA LIST 		FILE=DUMMY FIXED RECORDS=1/
				DUMMY(A1)

STRING			LYRIC1,LYRIC2,SPACE(A80)

LOOP			BOTTLES=99 TO 1 BY -1
COMPUTE		LYRIC1=CONCAT(STRING(BOTTLES,F2),
 				' BOTTLES OF BEER ON THE WALL, ',
				STRING(BOTTLES,F2),
				' BOTTLES OF BEER.')
COMPUTE		LYRIC2=CONCAT('TAKE ONE DOWN, PASS IT AROUND, ',
				STRING(BOTTLES-1,F2),
				' BOTTLES OF BEER ON THE WALL.')
WRITE			OUTFILE=BEERSONG RECORDS=3/
				LYRIC1/LYRIC2/SPACE
END LOOP
EXECUTE

FINISH
 
  Programming language: SQL
 
remark	99 bottles of beer with Oracle SQL*Plus
remark	R.vandePol@voeding.tno.nl	< Rob van de Pol>
remark
remark	assuming that YourTable contains at least 99 rows ;-)
remark
remark	RowNum is an Oracle psuedo column indicating the sequence the rows
remark	were selected.

SELECT 	TO_CHAR(100-rownum)||' bottles of beer on the wall, ' ||
		TO_CHAR(100-rownum)||' bottles of beer,' ,
	'take one down and pass it around, ' ,
	DECODE ( TO_CHAR(99-rownum) , '0' , 'No more' , TO_CHAR(99-rownum) )||
		' bottles of beer,'
FROM 	YourTable
WHERE 	rownum < 100
 
  Programming language: SR
 
# SR version of 99 bottles of beer
# by David Larsson 
# mailto:f92dala@dd.chalmers.se    http://www.dd.chalmers.se/~f92dala
#
# This version demonstrates some of SR's concurrent aspects, simulating
# the (common?) situation where 99 people drink one bottle of beer each
# simultaneously, while singing exactly one verse of the song.
#
resource main()
    op sing_it(int; string[120])

    # Create 99 processes (or, rather, threads)
    # for the verses in the song
    process swing_it(bottle := 1 to 99)
        var bottle1_str, bottle2_str : string[15];

        if bottle > 2 ->
            bottle1_str := string(bottle) || " bottles";
            bottle2_str := string(bottle-1) || " bottles";
        [] bottle = 2 ->
            bottle1_str := "2 bottles";
            bottle2_str := "1 bottle";
        [] else ->
            bottle1_str := "1 bottle";
            bottle2_str := "No more bottles";
        fi
        
        # Send the verse back to the main thread
        send sing_it(bottle, 
                  bottle1_str || " of beer on the wall, "
                   || bottle1_str || " of beer...\n"  
                   || "Take one down and pass it around\n" 
                   || bottle2_str || " of beer on the wall\n");
    end swing_it

    # Make sure the verses get printed in the right order
    fa expected := 99 downto 1 ->
        in sing_it(bottle, verse) st bottle = expected ->
            write(verse);
        ni
    af

    # I guess the bartender sings this one
    write("Go to the store, buy some more!");
    write("99 bottles of beer on the wall");
end main
 
  Programming language: StarBasic
 
sub Main
' Ninety-nine bottles of beer in StarBasic
' for usage in StarOffice/OpenOffice
'
' Daniel Hanke
' http://www2.hs-harz.de/~359/
' June 7, 2002
'

	oDesktop = createUnoService("com.sun.star.frame.Desktop")
	sUrl = "staroffice.factory:swriter"
	oDoc = oDesktop.LoadComponentFromURL(sURL,"_blank",0,mNoArgs)
	oText = oDoc.Text
	oCursor = oText.createTextCursor()

	dim bottles
	dim stext
	
	oCursor.CharHeight = 18
	p(oText,"99 bottles of beer")
	oCursor.CharHeight = 12
	for bottles = 99 to 1 step -1
		dim sbottle
		sbottle = cstr(bottles)+iif(bottles=1," bottle"," bottles")
		l(oText,sbottle+" of beer on the wall")
		l(oText,sbottle+" of beer ...")
		l(oText,"Take one down, pass it around,")
		l(oText,iif(bottles=1,"No more bottles",cstr(bottles-1)+_
			iif(bottles-1=1," bottle"," bottles"))+" of beer on the wall")
		p(oText,"")
	next bottles
	p(oText,"Time 2 go home")
end sub

sub l(otext as object,stext as string)
	otext.insertString(oCursor,stext,FALSE)
	otext.insertControlCharacter(oCursor,_
		com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,FALSE)
end sub

sub p(otext as object,stext as string)
	otext.insertString(oCursor,stext,FALSE)
	otext.insertControlCharacter(oCursor,_
		com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,FALSE)
end sub
 
  Programming language: StarLogo
 
; StarLogo version of 99 bottles of beer 
; by Uwe Kaessner (ukblue@friendsinside.de)
; StarLogo (http://www.media.mit.edu/starlogo) is based on Logo

to 99bottles
  let [:i 99]
  repeat 99 [
    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]
    print ""
    set :i (:i - 1)
  ]
end
 
  Programming language: Stata
 
/* Stata-Version of 99 bottles of beer     */
/* Stata is a program for doing statistics */
/* By Michael Hoefler                      */

#delimit;

for num 1/99:

disp "Bottle(s) of beer on the wall, " X \ disp " bottle(s) of beer"
 \
disp "Take one down and pass it around," 
\
disp X-1 "bottle(s) of beer on the wall" ;
 
  Programming language: Superbase
 
SUB main()
 REM "99 bottles of beer", Superbase SBL version
 REM written by Mark Pilgrim, f8dy@netaxs.com
 REM [ If my boss is reading this, I'd just like to reassure
 REM   him that I wrote this on my own time. -MP ]
 DIM i%%,beer$,bottle$
 OPEN WINDOW "99 bottles of beer"
 bottle$ = " bottles "
 beer$ = "99"
 FOR i%% = 99 TO 1 STEP - 1
   ? beer$ + bottle$ + "of beer on the wall,"
   ? beer$ + bottle$ + "of beer,"
   ? "Take " + IF (i%% > 1,"one","it") + " down, pass it around,"
   IF i%% > 1 THEN 
     beer$ = LTRIM$ ( TRIM$ ( STR$ (i%% - 1)))
     IF i%% = 2 THEN bottle$ = " bottle "
     ? beer$ + bottle$ + "of beer on the wall."
     ? 
   ELSE 
     ? "No more bottles of beer on the wall."
   END IF 
 NEXT 
 END SUB 
 
  Programming language: SuperTalk
 
on mouseup
put 99 into numBeerz
put "s it" into modifier
repeat with x = numBeerz down to 1
put "one" into whichone
put "s" into modifier
put "s" into otherModifier
put x - 1 into nextCount
if x is 2 then put "" into otherModifier
if x is 1 then
put "it" into whichone
put "" into modifier
put "s" into otherModifier
put "no more" into nextCount
end if

put x & " bottle" & modifier& " of beer on the wall, " & x & " bottle" & 
modifier & " of beer..." after y
put " Take " & whichOne & " down, pass it around, " & nextCount & " 
bottle" & otherModifier & " of beer on the wall. " & cr after y
end repeat
put "No more bottles of beer on the wall, ya bastards drank them all! So 
off to the store to buy some more, let's put 99 bottles of beer on the 
wall!" & cr after y

put y into card field 1
-- say cd fld 1 -- uncomment this line to hear it sing.

end mouseup
 
  Programming language: Surf
 
(begin 'SINGING

  (define HOW-MANY-BOTTLES
    (lambda (bottles where)
      (format stdout "%d bottle%d of beer%d\n"
	      (list (if (> bottles 0) bottles "No more")
		    (if (= bottles 1) "" "s")
		    where))))

  (recurse DRINKING (bottles 99)
    (how-many-bottles bottles " on the wall,")
    (how-many-bottles bottles ",")
    (if (= bottles 0)
	(display stdout "Go the the store, and buy some more!\n")
	(begin (display stdout "You take one down, pass it around,\n")
	       (how-many-bottles (- bottles 1) " on the wall.\n")
	       (drinking (- bottles 1)))))

  'GO-TO-THE-STORE)
 
  Programming language: Sybase SQL
 
-- Christopher D. Bain   April 2000
-- http://chris.bainland.net/
-- Sybase SQL version of 99 Bottles of Beer
-- Has been tested on Sybase 11.5 and 11.9.2

CREATE TABLE #BOTTLES (
   DIGIT  int,
   PL_TENS    char(1) null,
   PL_ONES char(1) null
)

CREATE TABLE #NOMORE (
   DIGIT  int,
   OUT    char(8)
)

insert into #BOTTLES values(0,null,'s')
insert into #BOTTLES values(1,'s',null)
insert into #BOTTLES values(2,'s','s')
insert into #BOTTLES values(3,'s','s')
insert into #BOTTLES values(4,'s','s')
insert into #BOTTLES values(5,'s','s')
insert into #BOTTLES values(6,'s','s')
insert into #BOTTLES values(7,'s','s')
insert into #BOTTLES values(8,'s','s')
insert into #BOTTLES values(9,'s','s')

insert into #NOMORE values(0,'No more')

select rtrim(convert(char(2),(tens.digit * 10) + ones.digit))
       + " bottle"
       + substring(tens.pl_tens + ones.pl_ones,1,1)
       + " of beer on the wall, "
       + rtrim(convert(char(2),(tens.digit * 10) + ones.digit))
       + " bottle"
       + substring(tens.pl_tens + ones.pl_ones,1,1)
       + " of beer,"
       + char(10)
       + "Take one down, pass it around,"
       + char(10)
       + substring(nm.out + rtrim(convert(char(2),((tens.digit * 10) +
ones.digit) - 1)),1,7)
       + " bottle"
       + ( select substring(tens2.pl_tens + ones2.pl_ones,1,1)
             from #BOTTLES ones2, #BOTTLES tens2
             where ones2.digit + tens2.digit * 10 = (ones.digit +
tens.digit * 10) - 1 )
       + " of beer on the wall."
       + char(10)
       as "Bottles of Beer"
from #BOTTLES tens, #BOTTLES ones, #NOMORE nm
where tens.digit * 10 + ones.digit > 0
and (tens.digit * 10 + ones.digit) - 1 *= nm.digit
order by tens.digit desc, ones.digit desc

drop table #BOTTLES
drop table #NOMORE
 
  Programming language: System 1032
 
See http://www.cca-int.com/prodinfo/s1032.html

Procedure CountTheBottles Trigger Open Enabled Secure
var bottles integer
for (bottles from 99 to 1 step -1) do
if bottles eq 1 then
print bottles (" bottle of beer on the wall")
print bottles (" bottle of beer...");
 else
print bottles (" bottles of beer on the wall")
print bottles (" bottles of beer...");
 end_if

print ("Take one down and pass it around...")
end_for

print ("No Bottles of beer on the wall")
End_Procedure

Call CountTheBottles
 
  © Oliver Schade <os@ls-la.net>, Generated: 06.06.2003 17:38:32