Skip to content

Instantly share code, notes, and snippets.

@kunjee17
Created July 24, 2018 12:21
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 kunjee17/e690eb88297016de6afde7bf2b2609d6 to your computer and use it in GitHub Desktop.
Save kunjee17/e690eb88297016de6afde7bf2b2609d6 to your computer and use it in GitHub Desktop.
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
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