Language OCaml
(recursive version)
Date: | 04/20/05 |
Author: | Walter C. Reel III |
URL: | n/a |
Comments: | 0 |
Info: | n/a |
Score: |
(* * 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
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
working with new versions, using printf | David Baelde | 11/08/05 | 0 | ![]() ![]() |
functional version | Anonymous | 04/20/05 | 0 | ![]() ![]() |
A little modification to the current one | Philippe Wang | 01/28/06 | 1 | ![]() ![]() |
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