Any difference between First Class Function and High Order Function

前端 未结 6 1492
小鲜肉
小鲜肉 2021-01-29 17:23

I\'m wondering whether/what difference between First Class Function and High Order Function.

I read through those two wiki pages and they looks rather similar. If they

6条回答
  •  天涯浪人
    2021-01-29 17:59

    There is a difference. When you say that a language has first-class functions, it means that the language treats functions as values – that you can assign a function into a variable, pass it around etc. Higher-order functions are functions that work on other functions, meaning that they take one or more functions as an argument and can also return a function.

    The “higher-order” concept can be applied to functions in general, like functions in the mathematical sense. The “first-class” concept only has to do with functions in programming languages. It’s seldom used when referring to a function, such as “a first-class function”. It’s much more common to say that “a language has/hasn’t first-class function support”.

    The two things are closely related, as it’s hard to imagine a language with first-class functions that would not also support higher-order functions, and conversely a language with higher-order functions but without first-class function support.

提交回复
热议问题