Instantly share code, notes, and snippets.

Embed
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
result
else
None
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 =
None
|> fizz n
|> buzz n
|> bang n
|> Option.defaultValue (string n)
let fizzBuzz =
[1..100] |> List.map fizzBuzzChecks
[<EntryPoint>]
let main argv =
fizzBuzz |> List.iter System.Console.WriteLine
System.Console.ReadLine() |> ignore
0
@ChrisCarrAu

This comment has been minimized.

Show comment
Hide comment
@ChrisCarrAu

ChrisCarrAu 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" 

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