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

(original version)

Date:04/20/05
Author:Philippe Lhoste
URL:n/a
Comments:1
Info:http://jove.prohosting.com/~philho/
Score: (3.07 in 665 votes)
-- Lua 99 Bottles of Beer
-- by Philippe Lhoste <PhiLho@GMX.net> http://jove.prohosting.com/~philho/

function PrintBottleNumber(n)
  local bs
  if n == 0 then
    bs = "No more bottles"
  elseif n == 1 then
    bs = "One bottle"
  else
    bs = n .. " bottles"
  end
  return bs .. " of beer"
end

for bn = 99, 1, -1 do
  write(PrintBottleNumber(bn), " on the wall, \n")
  write(PrintBottleNumber(bn), "\n")
  write("Take one down and pass it around,\n")
  write(PrintBottleNumber(bn-1), " on the wall, \n\n")
end
write("No more bottles of beer on the wall,\nNo more bottles of beer\n")
write("Go to the store, buy some more!\n")

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
5.1, bottledPeter Cawley04/19/090
Examples of metatables in lua 5.1Peter Cawley06/07/070
version 5.xchill07/10/052

Comments

>>  Space man said on 02/06/07 21:26:31

Space man Wow much better.. french people really appreciate good stuff, Including Programing languages... Regards

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: