Last active
June 4, 2017 15:15
-
-
Save jazzdan/d2d80dd6ac8587e0642e9795ae4cd64a to your computer and use it in GitHub Desktop.
Crackle Pop Implemented in Reason
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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