Skip to content

Instantly share code, notes, and snippets.

@NV
Created April 12, 2010 00:14
Show Gist options
  • Select an option

  • Save NV/363157 to your computer and use it in GitHub Desktop.

Select an option

Save NV/363157 to your computer and use it in GitHub Desktop.
queue(a, b, c)(arg) === c(b(a(arg)))
function queue(){
function runQueue(){
var result = arguments;
var args = runQueue.args;
for (var i=0; i<args.length; i++) {
result = [args[i].apply(this, result)];
}
return result[0];
}
runQueue.args = arguments;
return runQueue;
}
function a(s) {return s + 'a '}
function b(s) {return s + 'b '}
function c(s) {return s + 'c '}
queue(a, b, c)('Start: ') === c(b(a('Start: ')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment