Created
December 18, 2012 05:28
-
-
Save dvdsgl/4325309 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
type FizzBuzz = | |
FizzBuzz | Fizz | Buzz | Nat of int | |
let (|DivisibleBy|_|) by n = | |
if n % by = 0 then Some () else None | |
let fizzbuzz n = match n with | |
| DivisibleBy 3 & DivisibleBy 5 -> FizzBuzz | |
| DivisibleBy 3 -> Fizz | |
| DivisibleBy 5 -> Buzz | |
| _ -> Nat n | |
let fizzbuzzes = Seq.initInfinite fizzbuzz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of
| DivisibleBy 3 & DivisibleBy 5 -> FizzBuzz
You could do
| DivisibleBy 15 -> FizzBuzz
Cause if it's divisible by 3 & 5 it should be divisible by 15.