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
X++   XBasic   XLISP PLUS   XOTcl   XPLO   XS   xScript   XSLT  
 
  Programming language: X++
 
/* 
X++ (Axapta) version of 99 Bottles of beer
Tobias Nystrom, http://www.gangstasoftware.com
*/
static void bottles99()
{
    str         lyrics1, lyrics2, lyrics3;
    str         s = "s";
    int         bottles;
    ;
    lyrics1 = "%1 bottle%2 of beer on the wall%3 ";
    lyrics2 = "%1 bottle%2 of beer. ";
    lyrics3 = "Take one down, pass it around, ";

    for (bottles = 99; bottles >= 1; bottles--)
    {
        info(strFmt(lyrics1, int2str(bottles), s, ","));
        info(strFmt(lyrics2, int2str(bottles), s));
        info(lyrics3);

        if (bottles == 2) s = "";
        if (bottles == 1) s = "s";

        info(strFmt(lyrics1, int2str(bottles - 1), s, "."));
    }
}
 
  Programming language: XBasic
 
' XBasic version of 99 Bottles of beer (Bottles.x)
' See http://www.xbasic.org/
' Philipp Winterberg, http://www.winterbergs.de 
'
PROGRAM "99 Bottles of beer"
VERSION "1.0"
DECLARE FUNCTION  Bottles ()
FUNCTION  Bottles ()
FOR b = 99 TO 1 STEP -1
  PRINT b; " bottle(s) of beer on the wall,"
  PRINT b; " bottle(s) of beer."
  PRINT "Take one down, pass it around,"
  PRINT b-1; " bottle(s) of beer on the wall."
  PRINT " "
NEXT b
END FUNCTION
END PROGRAM
 
  Programming language: XLISP PLUS
 
;;; XLISP-PLUS version of 99 Bottles of beer (Bottles.lsp)
;;; http://www.aracnet.com/~tomalmy/xlisp.html
;;; Philipp Winterberg, http://www.winterbergs.de

(setq b 99)
(loop
   (format t "~D bottle(s) of beer on the wall,~%" b)
   (format t "~D bottle(s) of beer.~%" b)
   (format t "Take one down, pass it around,~%")
   (setq b (- b 1))
   (format t "~D bottle(s) of beer on the wall.~%~%" b)
   (when (= b 0) (return))
)

 
  Programming language: XOTcl
 
# XOTcl version of 99 Bottles of beer (Bottles.xotcl)
# http://www.xotcl.org
# Philipp Winterberg, http://www.winterbergs.de

for {set b 99} {$b > 0} {} {
  puts "$b bottle(s) of beer on the wall,"
  puts "$b bottle(s) of beer."
  puts "take one down, pass it around,"
  incr b -1
  puts "$b bottle(s) of beer on the wall.\n"
}

 
  Programming language: XPLO
 

\ XPLO version of 99 Bottles of beer (Bottles.xpl)
\ See http://www.idcomm.com/personal/lorenblaney/
\
\ Philipp Winterberg, http://www.winterbergs.de

code CRLF=9, INTOUT=11, TEXT=12;
integer B;

begin
  B:= 99;
  repeat	
    INTOUT(0, B); TEXT(0, " bottle(s) of beer on the wall,"); CRLF(0);
    INTOUT(0, B); TEXT(0, " bottle(s) of beer."); CRLF(0);
    TEXT(0, "Take one down, pass it around,"); CRLF(0);
    B:= B - 1;
    INTOUT(0, B); TEXT(0, " bottle(s) of beer on the wall."); CRLF(0);
    CRLF(0)
  until B = 0
end

 
  Programming language: XS
 
<for 
c1  = "XS version of 99 Bottles of beer (Bottles.xs)"
c2  = "Philipp Winterberg, http://www.winterbergs.de"
c3  = "See http://www.markcarter.me.uk/computing/xs.html"
var = "n" from = "99" to = "0" step = "-1">
<print>n, " bottle(s) of beer on the wall,\n", n,</print>
<print>" bottle(s) of beer.\nTake one down, and pass it around,\n",</print>
<print>n - 1, " bottle(s) of beer on the wall.\n"</print>
</for>

 
  Programming language: xScript
 
rem xScript version of 99 Bottles of beer (Bottles.xs)
rem See http://www.intelligent-data-systems.de/products/xccode.html
rem Philipp Winterberg, http://www.winterbergs.de

int b
string a,c,d,n
a = " bottle(s) of beer"
c = " on the wall"
d = "Take one down, pass it around," 
n = chr(13) + chr(10)
  for b = 99 to 1 step -1
    DisplayString cstr(b)+a+c+","+n+cstr(b)+a+"."+n+d+n+cstr(b-1)+a+c+"."
  next
 
  Programming language: XSLT
 
<?xml version="1.0"?>

<!-- 
     XSLT version of 99 Bottles of Beer
     author: Bernd Sokolowsky <ulmo@garozzo.franken.de>
     Erlangen/Germany, 11/2001
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>

<xsl:template match="/">
    <xsl:call-template name="loop"/>
</xsl:template>

<xsl:template name="bottles">
    <xsl:param name="bottles"/>

    <xsl:choose>
        <xsl:when test="$bottles = 0">
            <xsl:text>no bottles</xsl:text>
        </xsl:when> 
        <xsl:when test="$bottles = 1">
            <xsl:text>1 bottle</xsl:text>
        </xsl:when> 
        <xsl:otherwise>
            <xsl:value-of select="$bottles"/>
            <xsl:text> bottles</xsl:text>
        </xsl:otherwise>
     </xsl:choose>

</xsl:template>

<xsl:template name="loop">
    <xsl:param name="n" select="99"/>

    <xsl:call-template name="bottles">
        <xsl:with-param name="bottles" select="$n"/>
    </xsl:call-template>

    <xsl:text> of beer on the wall,</xsl:text>
    <xsl:value-of select="$newline"/>

    <xsl:call-template name="bottles">
        <xsl:with-param name="bottles" select="$n"/>
    </xsl:call-template>

    <xsl:text> of beer,</xsl:text>
    <xsl:value-of select="$newline"/>

    <xsl:text>take one down, pass it around,</xsl:text>
    <xsl:value-of select="$newline"/>

    <xsl:call-template name="bottles">
        <xsl:with-param name="bottles" select="$n - 1"/>
    </xsl:call-template>

    <xsl:text> of beer on the wall.</xsl:text>
    <xsl:value-of select="$newline"/>

    <xsl:if test="$n &gt; 1">
        <xsl:value-of select="$newline"/>
        <xsl:call-template name="loop">
            <xsl:with-param name="n" select="$n - 1"/>
        </xsl:call-template>
    </xsl:if>

</xsl:template>
</xsl:stylesheet>
 
  © Oliver Schade <os@ls-la.net>, Generated: 06.06.2003 17:38:32