Skip to content

Instantly share code, notes, and snippets.

@manveru
Created October 25, 2010 16:13
Show Gist options
  • Save manveru/645223 to your computer and use it in GitHub Desktop.
Save manveru/645223 to your computer and use it in GitHub Desktop.
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