I have many arrays of functions of variable length in which each function in an array takes a single argument of the same type and returns true or false.
How can I "compose" these functions together into a single function that tests that each and every component function returns true?
var less_than = function(y) {
function(x) {
return x < y;
}
}
var greater_than = function(y) {
function(x) {
return x > y;
}
}
var is_even = function(x) {
return x % 2 == 0;
}
var fns = [less_than(10), greater_than(1), is_even];
var test_function = combine_tests(fns);
test_function(8) // => true