Skip to content

Instantly share code, notes, and snippets.

@jonschoning
Forked from cscheid/monads.js
Created August 16, 2013 01:48
Show Gist options
  • Save jonschoning/6246563 to your computer and use it in GitHub Desktop.
Save jonschoning/6246563 to your computer and use it in GitHub Desktop.
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