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 LUA

(version 5.x)

Date:07/10/05
Author:chill
URL:n/a
Comments:2
Info:n/a
Score: (2.13 in 30 votes)
--LUA 5.x by CHILL CODE

-- for X = 99 to 2
-- X Bottles of beer on the wall, X bottles of beer.
-- Take one down and pass it around, [X-1] bottles of beer on the wall.
-- for X = 1
-- X Bottles of beer on the wall, X bottles of beer.
-- Take one down and pass it around, no more bottles of beer on the wall.
-- for X = 0
-- No more bottle of beer on the wall. No more bottles of beer... 
-- Go to the store and buy some more...99 bottles of beer.

for i = 99, 2 do
	write( i.." Bottles of beer on the wall, "..i.." bottles of beer." )
	write( "Take one down and pass it around, "..(i-1).." bottles of beer on the wall." )
end
write( "1 Bottles of beer on the wall, 1 bottles of beer." )
write( "Take one down and pass it around, no more bottles of beer on the wall." )
write( "No more bottle of beer on the wall. No more bottles of beer... " )
write( "Go to the store and buy some more...99 bottles of beer." )

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
original versionPhilippe Lhoste04/20/051
5.1, bottledPeter Cawley04/19/090
Examples of metatables in lua 5.1Peter Cawley06/07/070

Comments

>>  Space man said on 02/06/07 21:24:10

Space man Not really a good lua code. :p

>>  Jack Leunissen said on 03/23/07 00:32:14

Jack Leunissen The "for" statement should actually read "for i = 99, 2, -1 do" in order to work. As it is now, it will never enter the loop.

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: