Created
October 25, 2010 16:13
-
-
Save manveru/645223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Printf | |
open String | |
let bottles n = match n with | |
| 0 -> "no more bottles of beer" | |
| 1 -> "1 bottle of beer" | |
| n -> sprintf "%d bottles of beer" n | |
;; | |
let rec song n = match n with | |
| 0 -> ( | |
print_endline "No more bottles of beer on the wall, no more bottles of beer."; | |
print_endline "Go to the store and buy some more, 99 bottles of beer on the wall.") | |
| n -> ( | |
printf "%s on the wall, %s.\n" (bottles n) (capitalize (bottles n)); | |
printf "Take one down and pass it around, %s on the wall.\n\n" (bottles (n - 1)); | |
song (n - 1)) | |
;; | |
song 99 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment