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
R   Ramis Executive   Ramis SBX   Rapid Q   RapidBATCH   RBASIC   RC Shell   RealBasic   REBOL/Core   REBOL   Refal5   REXX   Robocode   Robot Scripting Language   RPG/400   Ruby   Runtime Revolution   Ruri   RXML  
 
  Programming language: R
 
# R version of 99 Bottles of beer (Bottles.r)
# See http://www.r-project.org/ for more informations
# Philipp Winterberg, http://www.winterbergs.de

for (b in 99:1){
  print(b)
  print(" bottle(s) of beer on the wall,")
  print(b)
  print(" bottle(s) of beer.")
  print("Take one down, pass it around,")
  print(b-1)
  print(" bottle(s) of beer on the wall.")
  print("")
}
 
  Programming language: Ramis Executive
 
*-----------------------------------------------------------------------
* 99 BOTTLES OF BEER ON THE WALL - RAMIS EXECUTIVE VERSION
*-----------------------------------------------------------------------

CATALOGS BEER
&&COUNT/I2 = 99;
&&LOOP
&&BOTTLES/A7 = IF &COUNT GT 1 THEN 'BOTTLES' ELSE 'BOTTLE ';
&&PRINT &COUNT &BOTTLES OF BEER ON THE WALL, &COUNT &BOTTLES OF BEER
&&PRINT TAKE ONE DOWN, PASS IT AROUND
&&COUNT/I2 = &COUNT - 1;
&&IF &COUNT GT 0 GOTO LOOP;
&&PRINT NO MORE BOTTLES OF BEER ON THE WALL, NO MORE BOTTLES OF BEER
&&PRINT GO TO THE STORE AND BUY SOME MORE
END CATALOGS
EXEC BEER
 
  Programming language: Ramis SBX
 
*----------------------------------------------------------------------
* 99 BOTTLES OF BEER ON THE WALL - RAMIS SBX VERSION
*----------------------------------------------------------------------

PROCESS;
DECLARE COUNT AS I2;
DO FROM COUNT = 99 TO 2 BY -1;
    PRINT &COUNT BOTTLES OF BEER ON THE WALL, &COUNT BOTTLES OF BEER;
    PRINT TAKE ONE DOWN, PASS IT AROUND;
ENDDO;

PRINT  1 BOTTLE  OF BEER ON THE WALL,  1 BOTTLE  OF BEER;
PRINT TAKE ONE DOWN, PASS IT AROUND;
PRINT NO MORE BOTTLES OF BEER ON THE WALL, NO MORE BOTTLES OF BEER;
 
  Programming language: Rapid Q
 
' Rapid-Q version of 99 Bottles of beer (Bottles.rqb)
' http://www.basicguru.com/rapidq/
' Philipp Winterberg, http://www.winterbergs.de 

$APPTYPE CONSOLE : $OPTIMIZE ON : $ESCAPECHARS ON : a$ = " _
\98\111\116\116\108\101\40\115\41 \111\102\32\98\101\101\11_
4" : b = 99 : while (b > 0) : print b, a$, " \111\110\32\11_
6\104\101\32\119\97\108\108," : print b, a$, ".\r\n\84\97\1_
07\101 \111\110\101 \100\111\119\110, \112\97\115\115 \105\_
116\32\97\114\111\117\110\100," : b = b - 1 : print b, a$, _
"\32\111\110\32\116\104\101\32\119\97\108\108\46\r\n" : wend
 
  Programming language: RapidBATCH
 
% RapidBATCH version of 99 Bottles of beer (Bottles.rb)
% http://www.jmksf.com/rbatch.html.
% Philipp Winterberg, http://www.winterbergs.de
Title 99 Bottles of Beer
Dec [b]
Let [b]=99
%next
EchoLn [b]
EchoLn bottle(s) of beer on the wall,
EchoLn [b]
EchoLn bottle(s) of beer.
EchoLn Take one down, pass it around,
CalcVar [b]=[b]-'1'
EchoLn [b]
EchoLn bottle(s) of beer on the wall.
If Not [b]='0' GoTo next
Wait
End

 
  Programming language: RBASIC
 
# RBASIC version of 99 Bottles of beer (Bottles.rbp)
# See http://www.rbasic.com/
# Philipp Winterberg, http://www.winterbergs.de
     
a$=" bottle(s) of beer":c$=" on the wall":d$=chr$(13)+chr$(10)
for b = 99 to 1 step -1 
  disp str$(b)+a$+c$+","+d$+str$(b)+a$+"."
  print "Take one down, pass it around, "
  print str$(b-1)+a$+c$+"."+d$+d$
next b
rpower=0:end
 
  Programming language: RC Shell
 
rc shell script language.

#!/usr/local/bin/rc
# rc shell version of 99 bottles of beer
# by Tom Culliton (culliton@clark.net)

count = (99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78
         77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56
         55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34
         33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12
         11 10 9 8 7 6 5 4 3 2 1)
bottles = bottles; one = one
for (i in $count) {
        if (~ $i 1) {bottles = bottle; one = it}
        if (! ~ $i 99) {
                echo $i $bottles 'of beer on the wall.'
                echo
        }
        echo $i $bottles 'of beer on the wall,'
        echo $i $bottles 'of beer,'
        echo 'take' $one 'down and pass it around,'
}
echo 'no more bottles of beer on the wall!'
 
  Programming language: RealBasic
 
// "99 Bottles of Beer on the Wall" for RealBasic (http://www.realsoftware.com/)
// Written by Uriah Carpenter
// To run add the below code to the "Open" event of a listbox
  
dim bottles as integer
dim plural as string
bottles = 99
plural = "s"
  
do
  me.addRow(str(bottles) + " bottle" + plural + " of beer on the wall, " +
str(bottles) + " bottle" + plural + " of beer.")
  bottles = bottles - 1
  if bottles = 1 then
    plural  = ""
  else
    plural = "s"
  end if
  me.addRow("Take one down, pass it around, " + str(bottles) + " bottle" +
plural + " of beer on the wall.")
loop until bottles = 0
 
  Programming language: REBOL/Core
 
; REBOL/Core version of 99 Bottles of beer (Bottles.r)
; See http://www.rebol.com/docs/core23/rebolcore.html
; Philipp Winterberg, http://www.winterbergs.de

REBOL [Title: "99 Bottles of beer"]

for b 99 1 -1 [
    prin b print " bottle(s) of beer on the wall,"
    prin b print " bottle(s) of beer."
    print "Take one down, pass it around,"
    prin b - 1 print " bottle(s) of beer on the wall."
    print ""
]
 
  Programming language: REBOL
 
REBOL [
    Title:   "99 Bottles of Beer Song"
    Date:    26-Apr-1998
    File:    %beersong.r
    Home:    http://www.reboltech.com/library/script-script.html
    Purpose: "The correct song. A bit more advanced."
    Category: [misc script 3]
    Note: {
        REBOL is pronounced like "rebel", and stands for
        Relative Expression-Based Object Language
    }
]

sing: func [count rest] [
    prin pick ["99 bottles " "no bottles " "1 bottle " [count "bottles "]]
        min 4 count + 2
    print rest
]

for bottles 99 0 -1 [
    sing bottles "of beer on the wall,"
    sing bottles "of beer."
    print pick [
        "Take one down, pass it around,"
        "Go to the store, buy some more,"
    ] bottles > 0
    sing bottles - 1 "of beer on the wall."
    print ""
]


 
  Programming language: Refal5
 
* Refal5 version of famous lyrics
* Created and debugged carefully by Dendik (ru.pochtamt[at]dendik)
* You can get some info on Refal at http://refal.org/index_e.htm

$ENTRY Go { = <Go 99>; t.n = <Go <Do t.n>>; };

Do
  {
   "next" t.n, <-(t.n)1> : { t.m = t.m; '-' 1 = 99; };
   "look" t.n = <Prout <Do "Look" t.n>>;
   "drink" t.n = <Prout <Do "Drink" t.n>'\n'> t.n;
   "Look" t.n = <Do "Beer" t.n> <Do "wall"> ', ' <Do "beer" t.n>;
   "Drink" 99 = 'Go to the store, buy some more' <Do "beer" 99>;
   "Drink" t.n = 'Take one down, pass it around, ' <Do "beer" t.n>;
   "wall" = ' on the wall';
   "Beer" 0 = 'No more ' <Do beer>;
   "Beer" t.n = t.n <Do beer>;
   "beer" 0 = 'no more ' <Do beer>;
   "beer" t.n = t.n <Do beer>;
   "beer" = 'bottles of beer';
   t.n = <Do "look" t.n> <Do "drink" <Do "next" t.n>>;
  };

 
  Programming language: REXX
 
/* Rexx Version of the Bottles program */
/* by Lee Stewart (ls@sweng.stortek.com) */
   Trace Off;
   Do Forever;
      Do i = 99 To 1 By -1;
         If i > 1 Then pl = 's';
                  Else pl = '';
         Say i 'bottle'pl 'of beer on the wall,' i 'bottle'pl 'of beer';
         Say 'Take one down, pass it around';
         End;
      Say 'No more bottles of beer on the wall, no more bottles of beer';
      Say 'Go to the store and buy some more';
      End;
 
  Programming language: Robocode
 
package wiki.beer;
import robocode.*;
import java.awt.geom.Point2D;

// BeerPoet, one way to go about writing the 99-bottles-of-beer poem.
// By Peter Strömberg, http://robowiki.dyndns.org/?PEZ
// For more info on the poem: http://99-bottles-of-beer.ls-la.net/
//
// Run this robot in Robocode.
// Put it against 99 SittingDuck and open its output window.

public class BeerPoet extends AdvancedRobot {
    private boolean hasStarted;

    public void run() {
        turnGunRightRadians(Double.POSITIVE_INFINITY); 
    }

    public void onScannedRobot(ScannedRobotEvent e) {
        if (!hasStarted) {
            printBottles();
            hasStarted = true;
        }
        setFire(3);
        setTurnGunRightRadians(0 - getGunTurnRemainingRadians());
    }

    public void onRobotDeath(RobotDeathEvent e) {
        printBottles();
    }

    private void printBottles() {
        out.println(bottles());
        if (getOthers() > 0) {
            out.println("Take " + (getOthers() == 1 ? "it" : "one") +
                " down, and pass it around");
            }
        else {
            out.println("Now they are all gone");
        }
    }

    private String bottles() {
        return bottles(getOthers()) + " on the wall, " + bottles(getOthers());
    }

    private String bottles(int bottles) {
        return (bottles == 0 ? "No" : "" + bottles) +
            " bottle" + (bottles == 1 ? "" : "s") + " of beer";
    }
}
 
  Programming language: Robot Scripting Language
 
# RSL version of 99 Bottles of Beer
# See http://www.robotbattle.com/
# By Ville Saalo, http://koti.mbnet.fi/villes/

Init
{
    Name( "99 Bottles of Beer" )
    Version( "1.6" )
    Author( "Ville Saalo" )
    Style( "Omicron" )

    print("New game!")
    print("")
    LockAll(1)
    RegCore( SingingAndFighting )
    if( _gamenbr > 10 )
        RegDtcWall( MeSeeWallMeGoNuts, 1 )
    endif

    if( bottles <= 0 )
        bottles = 99
    endif
}

SingingAndFighting
{
    if( bottles <= 0 )
        print("*Bottle delivery!*")
        bottles = 99
    endif
    GoSub( GetPlural )
    print(bottles+" bottle"+plural+" of beer on the wall")
    print(bottles+" bottle"+plural+" of beer")
    print("Take one down, pass it around")
    bottles = bottles-1
    GoSub( GetPlural )
    if( bottles > 0 )
        print(bottles+" bottle"+plural+" of beer on the wall")
        print("")
    else
        print("No more bottles of beer on the wall")
        msgbox("Go to the store, buy some more?")
        if( _result^2 == 1 )
         #-1 means the msgbox was redirected to print and 1 means "OK".
         #couldn't use abs() because it would have used _result and
         #I didn't want a new variable for it, so x^2==1 if abs(x)==1.
            print("---")
            bottles = 99
        else
            Suicide()
        endif
    endif

    GunLeft( (_dtcrobot==0)*5 )
    Scan()
    Fire( _dtcrobot*7 )
}

MeSeeWallMeGoNuts
{
    GetRandom(42)
    if( _result == 42 )
        print("")
        print(bottles+" bottles of beer on the wall")
        print(bottles+" bottles of beer")
        print("Shoot the wall down, drive over the debris")
        bottles = 0
        print("No more bottles of beer on the wall!")
        print("(I got bored...)")
        print("")
    endif
}

GetPlural
{
    if( bottles != 1 )
        plural = "s"
    else
        plural = ""
    endif
}

Dead
{
    print("Oh, the game ended. There were "+bottles+" bottles of beer on the wall left")
    Store(bottles)  #store the number for next match
}


 
  Programming language: RPG/400
 
     H*
     H* RPG/400 VERSION OF THE BOTTLES PROGRAM *
     H*
     FSCREEN  O   F      80            WORKSTN
     C                     MOVE 100       X       30
     C           X         DOWGE0
     C                     EXCPT
     C                     SUB  1         X
     C                     END
     C                     SETON                     LR
     OSCREEN  E
     O                         X          3
     O                                   26 'BOTTLES OF BEER ON THE'
     O                                   31 'WALL,'
     O                         X         36
     O                                   53 'BOTTLES OF BEER'
     O        E
     O                                   22 'TAKE ONE DOWN AND PASS'
     O                                   32 'IT AROUND'
 
  Programming language: Ruby
 
#99 Bottles of beer, in Ruby
#by Mike Gertz, Jan 5, 2003
#See www.rubycentral.com for info on the language.

class OneBottle
     def sing
	puts "One bottle of beer on the wall."
	puts "One bottle of beer."
	puts "Take it down, pass it around."
	puts "No more bottles of appear on the wall!"
     end
end

class TwoBottles
     def sing
	puts "Two bottles of beer on the wall."
	puts "Two bottles of beer."
	puts "Take one down, pass it around."
	puts "One bottle appears on the wall."
	puts 
     end
end

class Bottles
    attr_reader :number

    def Bottles.verse( number )
	if number > 2
	    Bottles.new( number )
        elsif number == 2
	    TwoBottles.new
	else
	    OneBottle.new
        end
    end

    def initialize( number )
        @number = number
    end

    def sing
	puts "#{number} bottles of beer on the wall."
	puts "#{number} bottles of beer."
	puts "Take one down, pass it around,"
	puts "#{number - 1} bottles appear on the wall!"
	puts
    end
end

99.downto(1) do | i |
    Bottles.verse(i).sing
end
 
  Programming language: Runtime Revolution
 
-- Runtime Revolution, a cross-platform environment for development and 
-- distribution
-- Jeanne deVoto and David Vaughan, 29 July 2002

global gDrinking
constant bottlePhrase = "more bottles of beer on the wall"
constant drinkPhrase = "Take one down and pass it around"
constant oneLeftPhrase = "One last bottle of beer on the wall"
constant singAlong = 2
constant startBottles = 99
local bottles

on openCard
   put startBottles into bottles
   DrinkThem
end openCard

on DrinkThem
   switch bottles
   case 0
     put startBottles into bottles
     put "No" && bottlephrase & ", no" && toLower(bottlephrase) & 
return & \
         "Go to the store and buy some more," && bottles && 
toLower(bottlephrase)
     break
   case 1
     put oneLeftPhrase & comma && toLower(oneLeftPhrase) & return \
         & drinkPhrase & comma && bottles - 1 && toLower(bottlephrase)
     break
   default
     put bottles && bottlePhrase & comma && bottles && 
toLower(bottlePhrase) \
         & return & drinkPhrase & comma && bottles - 1 && 
toLower(bottlephrase)
   end switch
   subtract 1 from bottles
   send DrinkThem to me in singAlong seconds
   put the result into gDrinking
end DrinkThem
 
  Programming language: Ruri
 
// Ruri version of 99 Bottles of beer.
// By Tom Rothamel <tom-ijvm@onegeek.org>
// 
// See http://onegeek.org/~tom/software/ruri/ for more info on the
// language.

main {
	word i;

	for (i = 99; i > 0; i) {
		printbottlesob(i);
		out " on the wall,\n";
		printbottlesob(i);
		out ".\n";
		
		i = i - 1;
		out "Take one down, pass it around,\n";
		printbottlesob(i);
		out " on the wall.\n\n";
	}

	halt;
}

method printbottlesob(word n) {
	word q;
	word oldn;

	oldn = n;

	if (n > 0) {
		q = 0;

		while (n >= 10) {
			n = n - 10;
			q = q + 1;
		}
	
		if (q) out '0' + q;
		out '0' + n;
	} else {
		out "No";
	}
		
	out " bottle";
	
	if (oldn != 1) out "s";
	
	out " of beer";

	return 0;
}



	
 
  Programming language: RXML
 
This version of 99 bottles is written in RXML, a markup language used
by the Roxen webserver, found at www.roxen.com. 

<comment>
99 bottles of beer on the wall in RXML
Written by Tomas Berndtsson <tomas@nocrew.org>
Tested in Roxen WebServer 2.1. 
</comment>

<set variable="var.pl" value="s"/>
<for variable="var.i" from="99" to="1">
 &var.i; bottle&var.pl; of beer on the wall,<br>
 &var.i; bottle&var.pl; of beer.<br>
 Take one down and pass it around,<br>
 <set variable="var.j" expr="&var.i; - 1"/>
 <if variable="var.j = 1"><set variable="var.pl" value=""/></if>
 <else><set variable="var.pl" value="s"/></else>
 <if variable="var.j = 0">No more</if>
 <else>&var.j;</else>
  bottle&var.pl; of beer on the wall.<p>
</for>


Greetings,

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