Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

99 Bottles of Beer
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!



Report this thread to moderator Post Follow-up to this message
Old Post
Frank J. Lhota
10-22-04 08:55 PM


Re: 99 Bottles of Beer
I 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




Report this thread to moderator Post Follow-up to this message
Old Post
David Liebtag
10-23-04 01:55 AM


Re: 99 Bottles of Beer
On 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


Report this thread to moderator Post Follow-up to this message
Old Post
TaliesinSoft
10-23-04 01:55 AM


Re: 99 Bottles of Beer
A 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


Report this thread to moderator Post Follow-up to this message
Old Post
TaliesinSoft
10-23-04 01:55 AM


Re: 99 Bottles of Beer
I 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




Report this thread to moderator Post Follow-up to this message
Old Post
David Liebtag
10-27-04 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

APL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:25 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.