Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language APL

(version one)

Date:05/22/05
Author:John A. Estep
URL:n/a
Comments:5
Info:n/a
Score: (2.54 in 13 votes)
    ' beer1;count;fc;s;s2
[1]   :for count :in ²¼99
[2]       fc".count ª s"(count¬1)/'s' ª s2"(count¬2)/'s'
[3]       fc,' bottle',s,' of beer on the wall, ',fc,' bottle',s,' of beer; take 1 down, pass it
around, ',(.count-1),' bottle',s2,' of beer on the wall.'
[4]   :endfor
    '

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
version twoJT. Taylor05/30/058

Comments

>>  Joat Mon said on 06/27/05 22:12:45

Joat Mon Too bad this isn't rendered in the APL character set. What can we do about that?

>>  Ian Osgood said on 07/12/05 19:36:52

Ian Osgood The APL operators are at Unicode code points #2336 through #237A. Can we specify that this page be rendered in a Unicode font that has these characters?

Alternatively, display as HTML with inline GIF's for the special symbols.

>>  Dave Gordon said on 10/20/05 15:53:35

Dave Gordon How about a version that's *not* explicitly iterative e.g. using an idiom such as

BEERVERSE <each> ,[0.5+<quadIO>] <reverse> <quadIO> - <commute> <iota> 100

Unfortunately the desktop APL that I'm using doesn't implement all the above operators, otherwise I might post it myself, but Dyalog APL and IBM's APL2 have all those operators -- and probably more, that might provide nicer ways of getting the verses down the page and avoiding quadIO dependencies too.

The coding of BEERVERSE itself is left as an exercise for the reader :)

>>  roger said on 02/08/06 00:17:08

roger A non-recursive APL version just doesn't seem right. Someone needs to implement as a self calling function.

>>  Don said on 03/26/06 21:39:15

Don It has been 20 years since I programmed in APL but this strikes me as an uninspired solution. What is needed is a simple matrix-based solution. It would also be the shortest and simplest, probably also the most efficient. I wouldn't even want to see it done in more than a single statement. No statement separators. No functions. No recursion. No looping. Just create the matrix, and since printing the resulting value is what happens to any statement's result, bingo! As I recall you don't need much more than the iota and rho operators for this sort of problem.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: