Created
July 9, 2011 20:52
-
-
Save showell/1073958 to your computer and use it in GitHub Desktop.
bizz_buzz on acid
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
# This extremely dubious code shows how to simulate | |
# a custom control structure in CS. bizz_buzz does | |
# a highly configurable loop through the integers. | |
bizz_buzz = (config) -> | |
i = 0 | |
while true | |
i += 1 | |
break if config.quit(i) | |
if config.bizz(i) && config.buzz(i) | |
console.log "bizzbuzz" | |
else if config.bizz(i) | |
console.log "bizz" | |
else if config.buzz(i) | |
console.log "buzz" | |
else | |
console.log i | |
if config.pause(i) | |
console.log "====== BEER BREAK" | |
console.log config.beer | |
console.log "=======" | |
bizz_buzz | |
bizz: (count) -> count % 5 == 0 | |
buzz: (count) -> count % 7 == 0 | |
pause: (count) -> count % 10 == 0 | |
beer: "Lager" | |
quit: (count) -> count == 40 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment