Skip to content

Instantly share code, notes, and snippets.

@kragen
Created August 22, 2012 21:21
Show Gist options
  • Save kragen/3429503 to your computer and use it in GitHub Desktop.
Save kragen/3429503 to your computer and use it in GitHub Desktop.
# Simplified CoffeeScript version of voting code from
# <http://www.cap-lore.com/CapTheory/Language/lambdaSecurity.html>:
# simplified from <https://gist.github.com/3429195>.
counter = ->
x = 0
voterMaker: ->
yet = true
-> if yet
yet = false
++x
votes: -> x
restaurants = ["Mandarin", "Casa Lupe", "Coffee Shop"]
lunchCrowd = ['Jim', 'Sue', 'Tom', 'Jennifer'];
noontime = ->
slate = for name in restaurants
name: name
counter: counter()
for e in lunchCrowd
SEND e, "Lunchtime!",
for r in slate
name: r.name
vote: r.voterMaker()
-> for r in slate
name: r.name
votes: r.counter.votes()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment