first-class function & Higher-order function

Posted gm-201705

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了first-class function & Higher-order function相关的知识,希望对你有一定的参考价值。

first-class function 头等函数

A first-class function is not a particular kind of function. All functions in Python are first-class functions. To say that functions are first-class in a certain programming language means that they can be passed around and manipulated similarly to how you would pass around and manipulate other kinds of objects (like integers or strings). You can assign a function to a variable, pass it as an argument to another function, etc. The distinction is not that individual functions can be first class or not, but that entire languages may treat functions as first-class objects, or may not.

Higher-order function 高阶函数

In mathematics and computerscience, a higher-order function (also functionalfunctional form or functor) is a function that does at least one of the following:

  • takes one or more functions as arguments (i.e. proceduralparameters),
  • returns a function as its result.

Currying 柯里化 

currying is the technique of translating the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single argument. For example, a function that takes two arguments, one from X and one from Y, and produces outputs in Z, by currying is translated into a function that takes a single argument from X and produces as outputs functions from Y to Z.Currying is related to, but not the same as, partialapplication.

以上是关于first-class function & Higher-order function的主要内容,如果未能解决你的问题,请参考以下文章

First-Class Functions

first-class function

Python笔记 · First-Class Functions | 函数是“一等”的

First-class citizen

First-class citizen

python functions as objects