Skip to content

Instantly share code, notes, and snippets.

@kiyui
Created February 21, 2018 14:30
Show Gist options
  • Save kiyui/98434661f43ad74f4aab52fcf680233f to your computer and use it in GitHub Desktop.
Save kiyui/98434661f43ad74f4aab52fcf680233f to your computer and use it in GitHub Desktop.
Fizz Buzz
/**
* Was watching this video by Tom Scott;-
* https://www.youtube.com/watch?v=QPZ0pIK_wsc
* And decided to try out the problem in ReasonML
*/
for (i in 1 to 100) {
let i = float(i);
let output = switch (mod_float(i, 3.0), mod_float(i, 5.0)) {
| (0.0, 0.0) => "FizzBuzz"
| (0.0, _) => "Fizz"
| (_, 0.0) => "Buzz"
| _ => string_of_float(i)
};
print_endline(output);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment