Skip to content

Instantly share code, notes, and snippets.

@doorhammer
Last active August 29, 2015 14:16
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 doorhammer/5e543f12d78f6423a318 to your computer and use it in GitHub Desktop.
Save doorhammer/5e543f12d78f6423a318 to your computer and use it in GitHub Desktop.
type FizzBuzz =
| Fizzy of int
| Buzzy of int
| FizzBuzzy of int
| NormalNumber of int
let fizzBuzz x =
match x with
| x when (x % 15) = 0 -> FizzBuzzy(x)
| x when (x % 5) = 0 -> Buzzy(x)
| x when (x % 3) = 0 -> Fizzy(x)
| _ -> NormalNumber x
let showFizzBuzz x =
match x with
| Fizzy x -> "Fizz"
| Buzzy x -> "Buzz"
| FizzBuzzy x -> "FizzBuzz"
| NormalNumber x -> string x
let typedFizzBuzz = [1 .. 100] |> List.map fizzBuzz
let stringFizzBuzz = typedFizzBuzz |> List.map showFizzBuzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment