Skip to content

Instantly share code, notes, and snippets.

@alexwirz
Created May 20, 2014 19:56
Show Gist options
  • Save alexwirz/cde4d861dd51bc13a037 to your computer and use it in GitHub Desktop.
Save alexwirz/cde4d861dd51bc13a037 to your computer and use it in GitHub Desktop.
fizz buzz with f#
module FizzBuzz
let fizzbuzzNumberProc x =
if x % 15 = 0 then "FizzBuzz"
elif x % 3 = 0 then "Fizz"
elif x % 5 = 0 then "Buzz"
else x.ToString ()
let fizzbuzzNumber x =
match x with
| x when x % 15 = 0 -> "FizzBuzz"
| x when x % 3 = 0 -> "Fizz"
| x when x % 5 = 0 -> "Buzz"
| _ -> x.ToString ()
let fizzbuzz =
List.map (fizzbuzzNumber) [1..100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment