Welcome! Log In Create A New Profile

Advanced

99 Bottles of Beer

Posted by gpredl 
99 Bottles of Beer
February 01, 2022 08:16AM
Hi,

http://99-bottles-of-beer.net]http://99-bottles-of-beer.net[/url] is a web site for comparison of programming languages. A simple program is to be written using the favorite programming language. Seemingly, hundreds of examples are there.

W-Language: [99-bottles-of-beer.net]

C++: [99-bottles-of-beer.net]

Compare the length of both examples!! The length of a program corresponds to the chances of errors!

Kind regards,
Guenter Predl
office@windev.at
Re: 99 Bottles of Beer
February 01, 2022 10:11AM
smileys with beer

Arie
Al
Re: 99 Bottles of Beer
February 01, 2022 07:26PM
Hello Guenter

The second line that I am familiar with is:
"And if one green bottle should accidentally fall, there'll be x green bottles hanging on the wall"

I appreciate that the C example was an exercise in a programming method but what a convoluted mess and it scored 3 stars.

Regards
Al
Re: 99 Bottles of Beer
February 02, 2022 06:38AM
Hi Al,

most top scoring programming languages are unknown to a broad audience. However, WLanguage does well in this concert.

Kind regards,
Guenter Predl
office@windev.at
Re: 99 Bottles of Beer
February 02, 2022 05:55PM
This one is … amazing!

[99-bottles-of-beer.net]
JP
Re: 99 Bottles of Beer
February 02, 2022 06:51PM
Seems a bit strange. Looking at the Visual FoxPro example - the coder uses far too many lines of code lines and even unneeded complex objects like containers and classes for the exact same output as these 7 lines below. Maybe I dont understand the challenge but it seems straight forward:


-----------

FOR i = 99 TO 1 STEP -1
? TRANSFORM(i) + " bottle" + IIF( i>1,"s","" ) + " of beer on the wall, " + TRANSFORM(i) + " bottle" + IIF( i>1,"s","" ) + " of beer."
? "Take one down, pass it around, " + IIF( i-1 = 0 , "no more" , TRANSFORM(i-1) ) + " bottle" + IIF( i-1 <> 1,"s","" ) + " of beer on the wall."
?
NEXT
? "No more bottles of beer on the wall, no more bottles of beer."
? "Go to the store and buy some more, 99 bottles of beer on the wall."

------------

So a lot depends on who is submitting the example. In fact, the VFP coder's output does not even match properly the lyrics or formatting of the example given by the website.



Edited 4 time(s). Last edit at 02/02/2022 07:01PM by JP.
JP
Re: 99 Bottles of Beer
February 02, 2022 07:59PM
And here is my Visual FoxPro version converted to WD:


FOR i = 99 TO 1 STEP -1
Trace( i + " bottle" + IIF( i>1 , "s" , "" ) + " of beer on the wall, " + i + " bottle" + IIF( i>1 , "s" , "" ) + " of beer." )
Trace( "Take one down, pass it around, " + IIF( i-1 = 0 , "no more" , i-1 ) + " bottle" + IIF( i-1 <> 1 , "s" , "" ) + " of beer on the wall." )
Trace( "" )
END
Trace( "No more bottles of beer on the wall, no more bottles of beer." )
Trace( "Go to the store and buy some more, 99 bottles of beer on the wall." )

INTERNAL PROCEDURE IIF( sExpression , sString1 , sString2 )

IF EvaluateExpression( sExpression ) = True THEN
RESULT( sString1 )
ELSE
RESULT( sString2 )
END

END
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: