Hi,

On 30/06/2022 06:28, Paul Gilmartin wrote:
On Wed, 29 Jun 2022 20:22:10 -0700, Charles Mills wrote:

    ...
"99 Bottles of Beer" is more concise in C++ than in Python, and MUCH more 
concise in BASIC. Does that make BASIC a better language? 
https://en.wikipedia.org/wiki/99_Bottles_of_Beer

The BASIC is 219 characters.  I converted it slavishly to Rexx.  32 characters 
shorter -- 187:

do Bottle = 100 TO 1 by -1
  say Bottle "bottles of beer on the wall," Bottle "bottles of beer"
  say "Take one down and pass it around," Bottle-1 "bottles of beer on the wall"
end Bottle
i
Does that make Rexx a worse language?

(We don't need no steenkin' "||"!)

The wikipedia article doesn't seem to be a comparison of how the *same* algorithm implemented in various languages.

Case 1 and 0 are treated as special cases for obvious reasons. And the loop 
ranges are also different.
Treating the last case(s) inside the loop or at the end? What is better? ... It 
depends ...
And the different names for the counter variable. :-)

e.g.: a python similar to the basic could be:

   for quant in range(99,1,-1):
       print(f"{quant} bottles of beer on the wall. {quant} bottles of beer.")
       print(f"Take one down and pass it around{quant-1} bottles of beer on the 
wall.")

One more line (or 2) to get the C++ equiv.

The database of these programs also contains quite funny examples which 
extremely obfuscated stuff. :-)

Best
Peter








----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to