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 Go!

Date:04/20/05
Author:John Knottenbelt
URL:n/a
Comments:1
Info:http://www.doc.ic.ac.uk/~klc/dalt03.html
Score: (2.90 in 40 votes)
-- 
-- 99 Bottles of Beer in Go!
-- John Knottenbelt
-- 
-- Go! is a multi-paradigm programming language that is oriented
-- to the needs of programming secure, production quality, agent
-- based applications.
-- 
--    http://www.doc.ic.ac.uk/~klc/dalt03.html 
-- 

main .. {
  include "sys:go/io.gof".
  include "sys:go/stdlib.gof".

  main() ->
      drink(99);
      stdout.outLine("Time to buy some more beer...").

  drink(0) -> {}.
  drink(i) -> stdout.outLine(
       bottles(i) <> " on the wall,\n" <>
       bottles(i) <> ".\n" <>
       "take one down, pass it around,\n" <>
       bottles(i) <> " on the wall.\n");
      drink(i-1).

  bottles(0) => "no bottles of beer".
  bottles(1) => "1 bottle of beer".
  bottles(i) => i^0 <> " bottles of beer".
}

Download Source | Write Comment

Alternative Versions

Comments

>>  Louis Franco said on 11/11/09 20:12:13

Louis Franco Shouldn't be bottles(i-1) after you take one down and pass it around?

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: