Skip to content

Instantly share code, notes, and snippets.

@MovGP0
Created August 16, 2017 18:31
Show Gist options
  • Save MovGP0/edc68af018bb6f79a10f7a0507ee4005 to your computer and use it in GitHub Desktop.
Save MovGP0/edc68af018bb6f79a10f7a0507ee4005 to your computer and use it in GitHub Desktop.
FizzBuzz
// inspired by FizzBuzz in Haskell by Embedding a Domain-Specific Language
// https://themonadreader.files.wordpress.com/2014/04/fizzbuzz.pdf
let fizzbuzz (number:int):string =
let test (d:int) (s:string) (x:string->string) = if number % d = 0 then (fun _ -> s + x("")) else x
let fizz = (fun (x:string->string) -> test 3 "Fizz" x)
let buzz = (fun (x:string->string) -> test 5 "Buzz" x)
((fun z -> z) |> buzz |> fizz) (number.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment