Skip to content

Instantly share code, notes, and snippets.

@showell
Created July 9, 2011 20:52
Show Gist options
  • Save showell/1073958 to your computer and use it in GitHub Desktop.
Save showell/1073958 to your computer and use it in GitHub Desktop.
bizz_buzz on acid
# 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