Skip to content

Instantly share code, notes, and snippets.

@Yuffster
Created January 3, 2011 21:28
Show Gist options
  • Select an option

  • Save Yuffster/764000 to your computer and use it in GitHub Desktop.

Select an option

Save Yuffster/764000 to your computer and use it in GitHub Desktop.
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