Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language GProlog

Date:04/20/05
Author:Paul J. DeMarco
URL:n/a
Comments:5
Info:n/a
Score: (3.11 in 362 votes)
/*******************************************************
 * 99 Bottles of Beer
 * Paul J. DeMarco  9/20/2002
 * beer.pro
 * To execute start gprolog (others may work)
 * consult('beer.pro').
 * drink(beer,99).
 *******************************************************/
english(beer,0):-
                        write('no more bottle of beer').
english(beer,1):-
                        write('1 bottle of beer').
english(beer,X):-
                        X >= 2,
                        write( X ) ,
                        write(' bottles of beer').
 
drink(beer,X):- X >= 1,
                        english(beer,X),
                        write(' on the wall, '),
                        english(beer,X),
                        write(', take one down, pass it around\n'),
                        X1 is X - 1,
                        english(beer,X1),
                        write(' on the wall.\n'),
                        drink(beer, X1).

Download Source | Write Comment

Alternative Versions

Comments

>>  Frederic said on 08/21/06 19:01:48

Frederic This is exactly what I was looking for. Works perfectly.

>>  Steve Smart said on 10/16/06 00:57:58

Steve Smart Brilliant!

>>  Braam said on 01/24/08 15:32:30

Braam Brilliant? because its writing it 99 times?
This is not even a Full lyrics version!..Far from brylliant!

>>  Tristan said on 01/28/08 09:20:51

Tristan LOL
this code is shorter than short

>>  mozzy said on 11/25/08 21:11:47

mozzy Works with SWI-Prolog as well.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: