Skip to content

Instantly share code, notes, and snippets.

@jazzdan
Last active June 4, 2017 15:15
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 jazzdan/d2d80dd6ac8587e0642e9795ae4cd64a to your computer and use it in GitHub Desktop.
Save jazzdan/d2d80dd6ac8587e0642e9795ae4cd64a to your computer and use it in GitHub Desktop.
Crackle Pop Implemented in Reason
let modulus numerator divisor => numerator - numerator / divisor * divisor;
let printNumberOrCracklePop number => {
let potentialCrackle = modulus number 3 == 0 ? "Crackle" : "";
let potentialPop = modulus number 5 == 0 ? "Pop" : "";
let potentialOutput = potentialCrackle ^ potentialPop;
if (potentialOutput == "") {
print_int number
} else {
print_string potentialOutput
}
};
for number in 1 to 100 {
printNumberOrCracklePop number;
print_string " "
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment