Skip to content

Instantly share code, notes, and snippets.

@melston
Created November 15, 2017 19:28
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/3f710bc78316f46de4c105f23ee580cc to your computer and use it in GitHub Desktop.
Save melston/3f710bc78316f46de4c105f23ee580cc to your computer and use it in GitHub Desktop.
let fizzbuzz2 rules n =
rules
|> List.choose
(fun (k, s) ->
match n % k with
| 0 -> Some s
| _ -> None )
|> function
| [] -> sprintf "%d" n
| e -> List.reduce (+) e
let rules = [(3, "fizz"); (5, "buzz"); (7, "bang")]
[1..150]
|> List.map (fizzbuzz2 rules)
|> List.iter (printfn "%s")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment