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 Caml Light

Date:04/20/05
Author:Bow-Yaw Wang
URL:n/a
Comments:1
Info:n/a
Score: (3.01 in 103 votes)
(* Caml Light version of 99 bottles of beer *)
(* Written by Bow-Yaw Wang (bywang@saul.cis.upenn.edu) *)
let rec bottles =
  function 1 -> print_string "1 bottle of beer on the wall, 1 bottle of beer\n";
                print_string "Take one down, pass it around,\n";
                print_string "no more bottles of beer on the wall\n"
         | n -> print_int n;
                print_string " bottles of beer on the wall, ";
                print_int n;
                print_string " bottles of beer\n";
                print_string "Take one down and pass it around,\n";
                print_int (n-1);
                print_string " bottles of beer on the wall\n";
                bottles (n-1)
in
   bottles 99;;

Download Source | Write Comment

Alternative Versions

Comments

>>  marteo said on 04/24/10 20:26:08

marteo There's a problem with 'bottles 2' : "1 bottleS of beer on the wall"
Wouldn't it be better to call 'bottles (n-1)' just after "pass it around" and modify the code in that way ?

Yours

marteo

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: