在数学与计算机科学中,至少具备以下特征之一的

    1. 拥有一个或多个函数类型的参数;
    2. 返回值是一个函数;

    就是,high-order function 高阶函数。

    与之对应的是 first-order functions,即普通函数。

    高阶函数在数学中也称之为: operators) or functionals)

    函数式编程中会大量使用高阶函数。

    常用的高阶函数有:
    map/sort/filter/…

    JavaScript 高阶函数示例:

    1. const twice = (f, v) => f(f(v));
    2. const add3 = v => v + 3;
    3. twice(add3, 7); // 13

    PHP 高阶函数示例:

    1. $twice = function($f, $v) {
    2. return $f($f($v));
    3. };
    4. $f = function($v) {
    5. return $v + 3;
    6. };
    7. echo($twice($f, 7)); // 13

    C 高阶函数示例:

    1. #include <stdio.h>
    2. typedef int (*int_func_int) (int);
    3. int add3(int x) {
    4. return x + 3;
    5. }
    6. int twice(int_func_int f, int v) {
    7. return f(f(v));
    8. }
    9. int main() {
    10. printf("%d\n”, twice(add3, 7) );
    11. return 0;
    12. }

    参考:https://en.wikipedia.org/wiki/Higher-order_function