Created
March 27, 2012 20:15
-
-
Save Termina1/2219907 to your computer and use it in GitHub Desktop.
Function with outter state
This file contains 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
generator = (times, callback) -> | |
i = 0 | |
-> | |
i++ | |
if i is times | |
do callback | |
# this pattern allows you to generate a new function with binded variables, that can be changed in this function, and also | |
# affect next calls. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment