Skip to content

Instantly share code, notes, and snippets.

@Termina1
Created March 27, 2012 20:15
Show Gist options
  • Save Termina1/2219907 to your computer and use it in GitHub Desktop.
Save Termina1/2219907 to your computer and use it in GitHub Desktop.
Function with outter state
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