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 Dylan

Date:04/20/05
Author:Anonymous
URL:n/a
Comments:1
Info:n/a
Score: (3.43 in 114 votes)
// Dylan version of 99 Bottles of Beer
// programmer: Jim Studt jim@federated.com

define method enumerate( count == 1 ) "1 bottle" end method enumerate;
define method enumerate( count == 0 ) "no more bottles" end method enumerate;
define method enumerate( count :: <integer> )
  format-to-string("%d bottles", count);
end method enumerate;

define method reference( count == 1) "it" end method reference;
define method reference( count :: <integer>) "one" end method reference;

define method main (argv0, #rest noise)
  for ( i from 99 to 1 by -1) 
    format( *standard-output*, "%s of beer on the wall, %s of beer.\n", 
	   enumerate(i), enumerate(i));
    format( *standard-output*, 
	   "  Take %s down, pass it around, %s of beer on the wall.\n",
	   reference(i), enumerate( i - 1));
  end for;
end method main;

Download Source | Write Comment

Alternative Versions

Comments

>>  Alex said on 04/08/07 00:00:42

Alex This reads realy clearly.

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: