Created
January 3, 2011 21:28
-
-
Save Yuffster/764000 to your computer and use it in GitHub Desktop.
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
| var print_to = (function(to) { | |
| var n = 1, print_n = (function() { | |
| if (n>to) { print_n = false; return; } | |
| console.log(n++); | |
| print_n(); | |
| }); | |
| print_n(); | |
| }); | |
| var print_too = (function(to) { | |
| var n = 1, fns = [function() { }], i; | |
| var print = function() { | |
| console.log(n++); | |
| i = n%(to+1); | |
| (fns[i] || print)(); | |
| }; | |
| print(); | |
| }); | |
| var print_2 = (function(to) { | |
| var n = 1, i, fns = [ | |
| function() { | |
| i = Math.floor(n%(to+1)/to); | |
| console.log(n++); | |
| fns[i](); | |
| }, function() { } | |
| ]; fns[0](); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment