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 groovy

Date:08/14/05
Author:Akihito Tsukamoto
URL:n/a
Comments:2
Info:http://groovy.codehaus.org/
Score: (3.00 in 63 votes)
def bottlesOfBeer(n) {
    return "" + (n==0 ? "no more" : n) + (n==1  ? " bottle" : " bottles") + " of beer";
}

99.downto(1) {
    println bottlesOfBeer(it)+" on the wall, " + bottlesOfBeer(it) + "!"
    println "Take one down, pass it around,"
    println bottlesOfBeer(it-1)+" on the wall!"
    println ""
}

Download Source | Write Comment

Alternative Versions

Comments

>>  Brad said on 03/08/08 22:27:19

Brad Nice tight, readable code. I'm looking at various scripting languages for my own personal use when I need to hack quick utilities. This sort of terseness and readability appeal to me.

>>  James said on 06/30/10 14:53:57

James Love this Language!!!!!!!!!!!!

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: