[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Documentation problem
- From: Eric Tetz <erictetz@...>
- Date: Wed, 6 Dec 2000 17:38:11 -0800 (PST)
--- Philippe Lhoste <PhiLho@MailAndNews.com> wrote:
> Of course, I checked to see if Lua was showcased. Not! So I choose to make my
> first Lua program with this exercice. Here is my work:
> function PrintBottleNumber(n)
> local bs
> if n == 0 then
> bs = "No more bottles"
> elseif n == 1 then
> bs = "One bottle"
> bs = n .. " bottles"
> return bs .. " of beer"
> 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")
> write("No more bottles of beer on the wall,\nNo more bottles of beer\n")
> write("Go to the store, buy some more!\n")
Bizarre... I just posted a Lua entry to that site a few weeks ago:
if n==0 then return 'no more bottles'
elseif n==1 then return '1 bottle'
else return n..' bottles'
while (n > 0)
print (bottle(n)..' of beer on the wall,')
print (bottle(n)..' of beer.\nTake one down,\npass it around,')
n = n - 1
print (bottle(n)..' of beer on the wall.\n')
Pretty dang close (though yours is a bit better).
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.