Skip to content

Instantly share code, notes, and snippets.

@cscheid
Created August 15, 2013 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cscheid/6241817 to your computer and use it in GitHub Desktop.
Save cscheid/6241817 to your computer and use it in GitHub Desktop.
sequence_ in javascript. sigh
function sequence_(lst)
{
function do_it(i) {
if (i === lst.length)
return;
lst[i](function() {
do_it(i+1);
});
}
do_it(0);
}
// abstract out continuation hell
sequence_([
function(k) { s.set('a', 1, k); },
function(k) { s.eval('cat(a)', k); },
function(k) { s.eval('print(a)', k); }
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment