Created
August 22, 2012 20:43
-
-
Save kragen/3429195 to your computer and use it in GitHub Desktop.
A CoffeeScript and corrected version of https://gist.github.com/3428922.
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
# CoffeeScript version of voting code from | |
# <http://www.cap-lore.com/CapTheory/Language/lambdaSecurity.html>: | |
mocntr = -> | |
x = 0 | |
voterMaker: -> | |
yet = true | |
-> if yet | |
yet = false | |
++x | |
votes: -> x | |
restaurants = ["Mandarin", "Casa Lupe", "Coffee Shop"] | |
lunchCrowd = ['Jim', 'Sue', 'Tom', 'Jennifer']; | |
lunchAgents = | |
for eater in lunchCrowd | |
(-> | |
cell = eater: eater | |
SEND eater, "LunchAgentAppointer", (agent) -> cell.agent = agent | |
cell)() | |
noontime = -> | |
bb = for restaurant in restaurants | |
restaurant: restaurant | |
counter: mocntr() | |
for e in lunchAgents | |
e.agent "Lunchtime!", | |
for r in bb | |
restaurant: r.restaurant | |
vote: r.voterMaker() | |
-> for r in bb | |
restaurant: r.restaurant | |
votes: r.counter.votes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment