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 Cat

Date:02/19/09
Author:Tim Locke
URL:n/a
Comments:0
Info:http://www.cat-language.com/
Score: (3.63 in 146 votes)
// 99-bottles-of-beer.cat
// by Tim Locke

define pluralize
{
	1 eq not [ "s" write ] [ "" write ] if
}

define bottles-of-beer
{
	0 eq
		[ "No more" ]
		[ dup -1 eq [ 99 ] [ dup ] if ] if write
	" bottle" write dup pluralize " of beer" write
}

define verse
{
	dup bottles-of-beer " on the wall," writeln
	dup bottles-of-beer "," writeln
	dup 0 eq
		[ "Go to the store and buy some more," ]
		[ "If " write
		  dup 1 eq [ "that" ] [ "one of those" ] if write
		  " bottle" write dup pluralize " should happen to fall,"
		] if writeln
	1 - dup bottles-of-beer " on the wall." writeln
	"" writeln
}

define beer-song
{
	99 [ verse ] [ dup 0 gteq ] while
}

beer-song

Download Source | Write Comment

Alternative Versions

Comments

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: