Skip to content

Instantly share code, notes, and snippets.

@lilactown
Created September 10, 2017 23:28
Show Gist options
  • Save lilactown/44a8fcc9b3804a817d1dab4879992ced to your computer and use it in GitHub Desktop.
Save lilactown/44a8fcc9b3804a817d1dab4879992ced to your computer and use it in GitHub Desktop.
FizzBuzz in Reason
let fizzbuzz num => {
let shouldFizz = num mod 3 == 0;
let shouldBuzz = num mod 5 == 0;
switch (shouldFizz, shouldBuzz) {
| (true, true) => "FizzBuzz"
| (true, false) => "Fizz"
| (false, true) => "Buzz"
| (false, false) => string_of_int num
}
};
for num in 0 to 30 {
print_endline (fizzbuzz num)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment