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 OCaml

(recursive version)

Date:04/20/05
Author:Walter C. Reel III
URL:n/a
Comments:0
Info:n/a
Score:No votes yet
(* 
 * O'Caml version of 99 bottles
 * by Walter C. Reel III 
 *)
let bottles n = if n = 1 then "1 bottle of beer" 
                else string_of_int n ^ " bottles of beer" in
let finale n = if n = 0 then "\nNo more bottles of beer on the wall!" 
               else ((bottles n) ^ " on the wall.\n\n") in
let round n = print_string ((bottles n) ^ " on the wall,\n");
              print_string ((bottles n) ^ ".\n");
              print_string "Take one down, pass it around.\n";
              print_string (finale (n-1)) in
let rec doit n =
  match n with
      0 -> ()
    | n -> round n; doit (n-1) in
doit 99;;

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
working with new versions, using printfDavid Baelde11/08/050
functional versionAnonymous04/20/050
A little modification to the current onePhilippe Wang01/28/061
version with recursive variant typePierre Etchemaïté11/18/051
historic versionPhilipp Winterberg04/20/050

Comments

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: