Code Comments
Programming Forum and web based access to our favorite programming groups.The following site does an amusing comparison of programming languages: http://99-bottles-of-beer.net/ The idea is to compare programming languages by applying them to one common problem: printing the lyrics to the song "99 Bottles of Beer"! This site includes presents 621 versions of the program. The variety of languages is stunning, including: - old time languages (Algol 60, Bliss, PL/1), - newer languages (Java, C++, Python), - scripting langages ( Bourne Shell, Korn Shell, VMS DCL and even DOS Batch!), and - "Joke" languages (Beatnik, BrainF*ck, Cow, INTERCAL). Noticable in its absense is an APL version of "99 Bottles", although there is a nice J implementation. I figure that someone in this newsgroup could rectify the situation. I urge you to take a look at the site, take a crack at writing the APL version of "99 Bottles of Beer" and submit it. APL should not be left out of this site!
Post Follow-up to this messageI thought I sent them an APL2 example years ago. I just sent it again.
SONG{<-}BEER COUNT;#IO
#IO{<-}1
TEXT{<-}4{rho}' bottles of beer on the wall,' ' bottles of beer,' 'Take one
down and pass it around.'
SONG{<- }{disclose}{disclose}({format}{each}{eac
h}({enclose}0 0 0
{neg}1)+{each}({enclose}1 1 0
1){rho}{each}{each}{reverse}{iota}COUNT)
,{each}{each}{enclose}TEXT
David Liebtag
IBM APL Products and Services
Post Follow-up to this messageOn Fri, 22 Oct 2004 13:56:41 -0500, Frank J. Lhota wrote (in article <JJced.172$Xq3.147@trndny01> ): > Noticable in its absense is an APL version of "99 Bottles" I just now, for fun and such, wrote, in Dyalog APL, a solution, but when I got finished I wondered if the number of bottles should be spelled-out, as in my version, or if they should just be digits. Here's a description of my solution.... I created three vectors, Ones, Teens, and Tens, and then appropriately joine d them together so I had character sequences expressing the values, e.g. Ninety-Nine Ninety-Eight .... Twenty Nineteen Eighteen .... Ten Nine .... Zero Having this vector it was then trivial to create a loop so that numeric values could be appropriately inserted. The solution is in Dyalog APL and uses an recursive dynamic function to compose the verses. -- James L. Ryan -- TaliesinSoft
Post Follow-up to this messageA couple of conditions when the numbers are stated as words and not digits. The opening and closing verses should read (using the lyrics we sang when I was in high school).... ========== Ninety-nine bottles of beer on the wall Ninety-nine bottles of beer If one of those bottles should happen to fall Ninety-eight bottles of beer on the wall Ninety-eight bottles of beer on the wall Ninety-eight bottles of beer If one of those bottles should happen to fall Ninety-seven bottles of beer on the wall ....... Two bottles of beer on the wall Two bottles of beer If one of those bottles should happen to fall One bottle of beer on the wall One bottle of beer on the wall One bottle of beer If that bottle should happen to fall No bottles of beer on the wall ========== Note that the unit values (nine, eight, etc.) are capitalized when they are the opening of a line but not when they are otherwise. And note that the wording of the last two verses is a bit different than the remaining verses, plurals being changed to singulars. I have no idea how much the solutions for other languages took any of these nuances into consideration. -- James L. Ryan -- TaliesinSoft
Post Follow-up to this messageI thought I sent them an APL2 example years ago. I just sent it again.
SONG{<-}BEER COUNT;#IO
#IO{<-}1
TEXT{<-}4{rho}' bottles of beer on the wall,' ' bottles of beer,' 'Take one
down and pass it around.'
SONG{<- }{disclose}{disclose}({format}{each}{eac
h}({enclose}0 0 0
{neg}1)+{each}({enclose}1 1 0
1){rho}{each}{each}{reverse}{iota}COUNT)
,{each}{each}{enclose}TEXT
David Liebtag
IBM APL Products and Services
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.