Created
June 1, 2013 20:43
-
-
Save davidgrenier/5691672 to your computer and use it in GitHub Desktop.
This file contains 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
let (|ModZero|_|) d v = | |
match v % d with | |
| 0 -> Some () | |
| _ -> None | |
let fizzBuzz = function | |
| ModZero 15 -> printfn "fizzbuzz" | |
| ModZero 3 -> printfn "fizz" | |
| ModZero 5 -> printfn "buzz" | |
| i -> printfn "%i" i | |
[0..30] | |
|> List.iter fizzBuzz | |
[for x in 0 .. 30 -> fizzBuzz] | |
|> List.iteri (fun i f -> f i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment