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
K   Kermit   Kiev   KiXtart   Korn Shell   KUIP   Kvikkalkul  
 
  Programming language: K
 
\d beer

s:"N bottles of beer on the wall, N bottles of beer.
Take one down, pass it around;
N-1 bottles of beer on the wall.

"

one:{_ssr[_ssr[after[s;"No more"];"N bottles";"1 bottle"];"one";"it"]}
two:{before[_ssr[s;"N-1 bottles";"1 bottle"];2]}
n:{before[after[s;$x-1];$x]}

before:{_ssr[x;"N";$y]}     / after after
after:{_ssr[x;"N-1";$y]}    / before before

beer:{|(one[]; two[]),n'3_!x+1}

sing:{`0:,/beer x}         / display the song
sing_file:{x 0: beer 99}   / write the (default) song to a file

 
  Programming language: Kermit
 
In case you missed it, Kermit is the communications program that 
seems to have been ported to just about everything, from the 
Timex Sinclair to the Cray II.

comment --- 99 bottles of beer, in Kermit scripting language.
comment --- Execute by using the TAKE command in Kermit, or naming
comment --- this file with the default initialization file name.
comment --- 23-Sep-1997 --- Scott Snadow, snadow@eisner.decus.org

set count 99
:loop
if < \v(count) 99 echo \v(count) bottle(s) of beer on the wall.
echo
echo \v(count) bottle(s) of beer on the wall, \v(count) bottle(s) of beer.
echo Take one down, pass it around,
if count goto loop
echo No bottles of beer on the wall.
 
  Programming language: Kiev
 
// Kiev version of 99 Bottles of beer (Bottles.java)
// See http://www.forestro.com/kiev/
// Philipp Winterberg, http://www.winterbergs.de

import kiev.stdlib;

class Bottles {
  public static void main(String argv[]) {
    int b;
    for (b = 99; b > 0; b--) {
      System.out.print(b);
      System.out.println(" bottle(s) of beer on the wall,");
      System.out.print(b);
      System.out.println(" bottle(s) of beer.");
      System.out.println("Take one down, pass it around,");
      System.out.print(b-1);
      System.out.println(" bottle(s) of beer on the wall.\n");
    }
  }
}
 
  Programming language: KiXtart
 
; KiXtart version of 99 Bottles of beer (Bottles.kix)
; Philipp Winterberg, http://www.winterbergs.de 
;
; KiXtart is a scripting language, see www.kixtart.org
;
cls                              
color w/n

$bob  = " bottles of beer"
$wall = $bob + " on the wall"
$take = "Take one down, pass it around, "

for $b = 99 to 1 step -1
  select 
    case $b = 1
      ? "One bottle of beer on the wall," ? "One bottle of beer."
      ? $take ? "No more" $wall "."
    case $b = 2
      ? $b $wall "," ? $b $bob "."
      ? $take ? "One bottle of beer on the wall."
    case $b > 2
      ? $b $wall "," ? $b $bob "."
      ? $take ? ($b - 1) $wall "."
  endselect
  ?
next
                     
color r+/n+
sleep 1

? "No more" $wall "," ? "No more" $bob "."
? "Go to the store and buy some more," ? "99" $wall "."

get $MoreBeer
quit

 
  Programming language: Korn Shell
 
Yet another UN*X shell.

#!/bin/ksh
# Korn shell version of 99 Bottles
# Dave Plonka - plonka@carroll1.cc.edu

typeset -i n=99
typeset bottles=bottles
typeset no

while (( n ))
do
   print "${n?} ${bottles?} of beer on the wall,"
   print "${n?} ${bottles?} of beer,\ntake one down, pass it around,"
   n=n-1
   case ${n?} in
   0)
      no=no
      bottles=${bottles%s}s
      ;;
   1)
      bottles=${bottles%s}
      ;;
   esac
   print "${no:-${n}} ${bottles?} of beer on the wall.\n"
done

exit
 
  Programming language: KUIP
 
*******************************************
* KUIP version of 99 bottles of beer      *
* r.p.hofmann f15rph@ips105.desy.de       *
* http://ips105.desy.de:8765/             *
*******************************************
* about KUIP:                             *
* R.Brun, P.Zanarini                      *
* KUIP - Kit for a User Interface Package *
* Program library I202. CERN 1988         *
*******************************************

macro beer nbott=99 ndown=1

  if [ndown] > 0 goto ndok
  ndown=-[ndown]
ndok:
  if [ndown] > 1 goto mored
  alias/create pron it
  goto oned
mored:
  alias/create pron them
oned:
  if [nbott] < 1 goto end
  if [nbott] = 1 goto one
  alias/create bob 'bottles of beer'
  alias/create otw 'on the wall'
pass:
  mess [nbott] bob otw
  mess [nbott] bob
  mess take [ndown] down and pass pron all around 
  nbott=[nbott]-[ndown]
  if [nbott] <> 1 goto moreb
  mess 1 bottle of beer otw
  goto oneb
moreb:  
  mess [nbott] bob otw
oneb:
  if [ndown] = 0 goto end
  if [nbott] > 1 goto pass
  if [nbott] < 1 goto end
one:
  mess 1 bottle of beer otw
  mess 1 bottle of beer
  mess take [ndown] down and pass pron all around
  nbott=1-[ndown]
  mess [nbott] bottles of beer otw
  if [nbott] < 1 goto end
end:
 
  Programming language: Kvikkalkul
 
Kvikkalkul version of 99 bottles of beer
Laurent Vogel,  http://lvogel.free.fr
the actual Kvikkalkul code starts after after the line below.

(0) (- ,84375
20/ 10
/0 -) 20
/0 (- ,09375
/0 ))
/0 (- ,37500
/0 ))
/0 (- ,87500
/0 ))
/0 (- ,65625
/0 ))
/0 (- ,03125
/0 ))
/0 (- ,31250
/0 ))
/0 (- ,50000
/0 ))
/0 (- ,78125
/0 ))
/0 (- ,90625
/0 ))
/0 (- ,40625
/0 -) 20
/1 -) 20
:1 -) 1200
:2 -) 1300
1100:
:0 -) 1101
-) :2
1101:
:0 -) 1102
-) :1
1102:
(0) (- ,84375
(0) (- ,18750
(0) (- ,06250
(0) (- ,25000
:0 -) 1103
-) :2
1103:
(0) (- ,84375
(0) (- ,21875
(0) (- ,96875
(0) (- ,06250
(0) (- ,25000
(0) (- ,03125
(0) (- ,75000
(0) (- ,93750
(0) (- ,50000
(0) (- ,12500
(0) (- ,09375
(0) (- ,18750
(0) (- ,50000
(0) (- ,12500
(0) (- ,56250
(0) (- ,09375
(0) (- ,78125
(0) (- ,18750
(0) (- ,84375
(0) (- ,18750
(0) (- ,96875
(0) (- ,12500
(0) (- ,40625
(0) (- ,75000
(0) (- ,62500
(0) (- ,62500
(0) (- ,12500
(0) (- ,37500
(0) (- ,03125
(0) (- ,12500
(0) (- ,75000
(0) (- ,31250
(0) (- ,09375
(0) (- ,87500
(0) (- ,18750
(0) (- ,56250
(0) (- ,84375
(0) (- ,18750
(0) (- ,06250
(0) (- ,25000
:3 -) 1104
.0 (- /1
.0 :: ,40625 -) :3
/1 ))
:3 -) 1105
-) :3
1104:
/1 -) 20
/0 ))
1105:
:0 -) 1106
-) :2
1106:
:0 -) 1107
-) :1
1107:
(0) (- ,84375
(0) (- ,21875
(0) (- ,06250
(0) (- ,25000
:3 -) 1108
.0 (- /0
.0 :/: ,40625 -) :3
.0 (- /1
.0 :/: ,40625 -) :3
:3 -) 1400
-) :3
1108:
(0) (- ,06250
(0) (- ,25000
:3 -) 1100
-) :3
1200:
(0) (- ,12500
(0) (- ,09375
(0) (- ,18750
(0) (- ,12500
(0) (- ,03125
(0) (- ,15625
(0) (- ,50000
(0) (- ,12500
(0) (- ,78125
(0) (- ,75000
(0) (- ,28125
(0) (- ,28125
-) :0
1300:
.0 (- /0
:3 -) 1301
:4 -) 1302
:5 -) 1303
.0 :: ,40625 -) :3
(0) (- .0
.0 (- /1
1302:
(0) (- .0
-) :5
1301:
.0 (- /1
.0 :/: ,40625 -) :4
(0) (- ,96875
(0) (- ,18750
(0) (- ,09375
(0) (- ,12500
(0) (- ,21875
(0) (- ,09375
(0) (- ,31250
(0) (- ,50000
1303:
(0) (- ,96875
(0) (- ,12500
(0) (- ,59375
(0) (- ,09375
(0) (- ,03125
(0) (- ,03125
(0) (- ,28125
(0) (- ,50000
:3 -) 1304
.0 (- /0
.0 :/: ,40625 -) :3
.0 (- /1
.0 :/: ,90625 -) :3
:3 -) 1305
-) :3
1304:
(0) (- ,62500
1305:
(0) (- ,12500
(0) (- ,09375
(0) (- ,68750
(0) (- ,12500
(0) (- ,59375
(0) (- ,50000
(0) (- ,50000
(0) (- ,31250
-) :0 
1400:
 
  © Oliver Schade <os@ls-la.net>, Generated: 06.06.2003 17:38:32