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 Matlab

(standard version)

Date:04/20/05
Author:Bill Becker
URL:n/a
Comments:1
Info:http://www.mathworks.com
Score: (2.67 in 12 votes)
a href=http://www.mathworks.com>Click</a> for more information.

% MATLAB verion of 99 Bottles of beer
% by Bill Becker

function beer(n);
if nargin<1, n=99; end
for i=n:-1:1,
  disp([int2str(i) ' Bottles of beer on the wall,'])
  disp([int2str(i) ' Bottles of beer,'])
  disp('Take one down and pass it around,')
  if i>1, disp([int2str(i-1) ' Bottles of beer on the wall.']),end
  end
disp('No more bottles of beer on the wall!')

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
vectorized versionRich Stein04/20/050
RecursiveWilliam Rossi11/24/080

Comments

>>  Elon Weintraub said on 04/06/06 01:02:35

Elon Weintraub It sings "1 bottles" in the plural instead of the more grammatically correct "1 bottle".

I fixed this in my version, which is right now twice the length of yours. So there is a tradeoff for everything. But I will find a way to shorten it.

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: