Skip to content

Instantly share code, notes, and snippets.

@pomber
Created May 6, 2018 13:37
Show Gist options
  • Save pomber/ba5855a15ef60247770832cd12b3ecc1 to your computer and use it in GitHub Desktop.
Save pomber/ba5855a15ef60247770832cd12b3ecc1 to your computer and use it in GitHub Desktop.
import R from "ramda";
var divisibleBy = R.curry(R.pipe(R.flip(R.modulo), R.equals(0)));
var fizzbuzz = R.map(
R.cond([
[R.both(divisibleBy(3), divisibleBy(5)), R.always("FizzBuzz")],
[divisibleBy(3), R.always("Fizz")],
[divisibleBy(5), R.always("Buzz")],
[R.T, R.identity]
])
);
console.log(fizzbuzz(R.range(1, 16)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment