Skip to content

Instantly share code, notes, and snippets.

@frankstallone
Created March 18, 2014 11:07
Show Gist options
  • Save frankstallone/9617993 to your computer and use it in GitHub Desktop.
Save frankstallone/9617993 to your computer and use it in GitHub Desktop.
Function Queue
var puzzlers = [
function ( a ) { return 8*a - 10; },
function ( a ) { return (a-3) * (a-3) * (a-3); },
function ( a ) { return a * a + 4; },
function ( a ) { return a % 5; }
];
var start = 2;
var applyAndEmpty = function( input, queue ) {
var length = queue.length;
for(var i = 0; i<length; i++){
input = queue.shift()(input);
}
return input;
};
alert(applyAndEmpty(2, puzzlers));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment