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
Yabasic   Yacas   Yacc   Yoix   Yorick  
 
  Programming language: Yabasic
 
rem Yabasic version of 99 Bottles of beer (Bottles.yab)
rem See http://www.yabasic.de/
rem Philipp Winterberg, http://www.winterbergs.de 

b = 99 
while (b > 0)
  print b, " bottle(s) of beer on the wall,"
  print b, " bottle(s) of beer."
  print "Take one down, pass it around,"
  b = b - 1
  print b, " bottle(s) of beer on the wall." + chr$(13) + chr$(10)
wend
 
  Programming language: Yacas
 
// Yacas version of 99 Bottles of beer (Bottles.ys)
// Yacas = Yet Another Computer Algebra System
//         http://yacas.sourceforge.net/yacas.html
//
// Philipp Winterberg, http://www.winterbergs.de

For (b := 99, b > 0, b--) 
  Echo({b, "bottle(s) of beer on the wall," : Nl(),
        b, "bottle(s) of beer." : Nl(),
        "Take one down, pass it around," : Nl(),
        b - 1, "bottle(s) of beer on the wall." : Nl()});

 
  Programming language: Yacc
 
%{
/*
** 99 bottles of beer yacc-like
** by: James Copher jec@netcom.com
*/

#include<stdio.h>
static int bottles=99;
%}

%union{ int bottle; }
%token <bottle> BOTTLES NOMORE
%type <bottle> beer nomore
%start round

%%
round    : beer nomore {
            YYACCEPT;
        };
beer    : BOTTLES {
            printf("%d bottles of beer on the wall\n%d bottles of beer\n"
                "Take one down,\npass it around\n",$1,$1);
        }
        | beer BOTTLES {
            printf("%d bottle%s of beer on the wall\n\n"
                "%d bottle%s of beer on the wall\n%d bottle%s of beer\n"
                "Take one down\npass it around\n",
                $2,$2!=1?"s":"",$2,$2!=1?"s":"",$2,$2!=1?"s":"");
        };
nomore	: NOMORE {
            printf("No more bottles of beer on the wall\n");
        };
%%

yyerror(){}
yylex(){ if(bottles){ yylval.bottle=bottles--; return BOTTLES; } return NOMORE; }
main(){ yyparse(); }
 
  Programming language: Yoix
 
// Yoix version of 99 Bottles of beer (Bottles.yx)
// See http://www.research.att.com/sw/tools/yoix/index.html
//
// Philipp Winterberg, http://www.winterbergs.de

import yoix.stdio.printf;

for (b = 99 ; b > 0 ; b--) 
      printf("%d %s\n%d %s\n%s\n%d %s\n\n", b, "bottle(s) of beer on the wall,",	
              b, "bottle(s) of beer.", "Take one down, pass it around,",
             (b - 1), "bottle(s) of beer on the wall.");
 
  Programming language: Yorick
 
/*  The Bottles of Beer song (c) 1996 Eric Korpela
 *   Yorick version-- Modeled after the IDL version.
 * USAGE:  bottles or bottles, number
 */

/* Set up our song structure............ */

struct _song {
  int n0;
  string s1;
  int n1;
  string s2,s3;
  int n2;
  string s4;
} 

func bottles( number )
{

  if (is_void(number)) { 
    number=99
    write,"BOTTLES: Defaulting to 99 bottles!"
  }
 
  song=array(_song(n0=0,s1=" bottles of beer on the wall.\n",n1=0,
                   s2=" bottles of beer.\n",
                   s3="You take one down and pass it around\n",
                   n2=0,
                   s4=" bottles of beer on the wall.\n"), number)

  /* put in the appropriate numbers */

  i=(number)-indgen(number)
  song(*).n0=i+1
  song(*).n1=i+1
  song(*).n2=i
 
  write,song.n0,song.s1,song.n1,song.s2,song.s3,song.n2,song.s4
 
}
 
  © Oliver Schade <os@ls-la.net>, Generated: 06.06.2003 17:38:32