Skip to content

Instantly share code, notes, and snippets.

@melston
Created November 15, 2017 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melston/7025207644807d2ab729893b260ef4a5 to your computer and use it in GitHub Desktop.
Save melston/7025207644807d2ab729893b260ef4a5 to your computer and use it in GitHub Desktop.
let genFB (v: int, s: string) =
fun (n, os) ->
match n%v with
| 0 -> (n, os+s)
| _ -> (n, os)
let getStr (v: int, s: string) =
if (String.length s > 0) then s else sprintf "%i" v
let fizzbuzz max =
seq {1..max}
|> Seq.map ( fun n -> (n, "") )
|> Seq.map ( genFB(3, "fizz") )
|> Seq.map ( genFB(5, "buzz") )
|> Seq.map ( genFB(7, "bang") )
|> Seq.map ( getStr )
|> Seq.iter ( fun s -> printfn "%s" s )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment