Created
July 24, 2018 12:21
-
-
Save kunjee17/e690eb88297016de6afde7bf2b2609d6 to your computer and use it in GitHub Desktop.
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
let fizzBuzz x = | |
match x with | |
| _ when (x % 15) = 0 -> "FizzBuzz" | |
| _ when (x % 3) = 0 -> "Fizz" | |
| _ when (x % 5) = 0 -> "Buzz" | |
| _ -> "" | |
let fizzBuzzTo max = | |
[1..max] | |
|> List.iter (fun number -> printfn "%d %s" number (fizzBuzz number)) | |
|> ignore | |
fizzBuzzTo 100 |
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
import { range, toList, iterate } from "fable-core/Seq"; | |
import { printf, toConsole } from "fable-core/String"; | |
export function fizzBuzz(x) { | |
if (x % 15 === 0) { | |
return "FizzBuzz"; | |
} else if (x % 3 === 0) { | |
return "Fizz"; | |
} else if (x % 5 === 0) { | |
return "Buzz"; | |
} else { | |
return ""; | |
} | |
} | |
export function fizzBuzzTo(max) { | |
iterate(function (number) { | |
toConsole(printf("%d %s"))(number, fizzBuzz(number)); | |
}, toList(range(1, max))), void 0; | |
} | |
fizzBuzzTo(100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment