Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
let is divisor outputString n result =
if n % divisor = 0 then
Some ( (result |> Option.defaultValue("")) + outputString)
else if result.IsSome then
let fizz x s = is 3 "fizz" x s
let buzz x s = is 5 "buzz" x s
let bang x s = is 7 "bang" x s
let fizzBuzzChecks n =
|> fizz n
|> buzz n
|> bang n
|> Option.defaultValue (string n)
let fizzBuzz =
[1..100] |> fizzBuzzChecks
let main argv =
fizzBuzz |> List.iter System.Console.WriteLine
System.Console.ReadLine() |> ignore

This comment has been minimized.

Copy link

@ChrisCarrAu ChrisCarrAu commented Feb 28, 2018

You can also leave off the x s as follows:

let fizz = is 3 "fizz" 
let buzz = is 5 "buzz" 
let bang = is 7 "bang" 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment