Created
August 16, 2017 18:31
-
-
Save MovGP0/edc68af018bb6f79a10f7a0507ee4005 to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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