Created
May 21, 2015 08:17
-
-
Save bendc/6cb2db4a44ec30208e86 to your computer and use it in GitHub Desktop.
Functional loop
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
const loop = (() => { | |
const recur = (callback, count, i=0) => { | |
if (i == count-1) return callback(i); | |
callback(i); | |
return recur(callback, count, i+1); | |
}; | |
return (callback, count) => { | |
if (count > 0) return recur(callback, count); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: