Language OCaml
(A little modification to the current one)
Date: | 01/28/06 |
Author: | Philippe Wang |
URL: | http://mythoughts.free.fr/ |
Comments: | 1 |
Info: | http://caml.inria.fr/ |
Score: | (3.01 in 117 votes) |
(* this is only a little modification of the current code by Walter C. Reel III *) (* in deed, I just made it be a little more ``Caml-looking'' *) let bottles n = string_of_int n ^ " bottle" ^ (if n = 1 then "" else "s") ^ " of beer" in let finale = function 0 -> "\nNo more bottles of beer on the wall!" | n -> ((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 (pred n)) in let rec doit = function 0 -> () | n -> round n; doit (pred n) in doit 99;;
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
working with new versions, using printf | David Baelde | 11/08/05 | 0 | |
functional version | Anonymous | 04/20/05 | 0 | |
version with recursive variant type | Pierre Etchemaïté | 11/18/05 | 1 | |
historic version | Philipp Winterberg | 04/20/05 | 0 |
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!
Comments
Frank Thieme said on 09/20/07 19:56:41
Very nice...
0 -> "\nNo more bottles of beer on the wall!"
There should be another \n at the end of the line, IMHO.