Created
March 17, 2014 14:18
-
-
Save theotherzach/9600002 to your computer and use it in GitHub Desktop.
...and F#...cause...I'm an asshole
type Bottles() =
member x.verse(number) =
match number with
| 0 -> "No more bottles of beer on the wall, no more bottles of beer.\n\
Go to the store and buy some more, 99 bottles of beer on the wall.\n"
| 1 -> "1 bottle of beer on the wall, 1 bottle of beer.\n\
Take it down and pass it around, no more bottles of beer on the wall.\n"
| 2 -> "2 bottles of beer on the wall, 2 bottles of beer.\n\
Take one down and pass it around, 1 bottle of beer on the wall.\n"
| _ -> sprintf "%d bottles of beer on the wall, %d bottles of beer.\n\
Take one down and pass it around, %d bottles of beer on the wall.\n" number number (number - 1)
member x.verses(start, finish) =
if start = finish then sprintf "%s\n" (x.verse finish)
else sprintf "%s\n%s" (x.verse start) (x.verses((start - 1), finish))
member x.sing() =
x.verses(99, 0)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah Zach, we have talked about this one sooooo much in the past, I feel like I know where this might be going....