For faster navigation, this Iframe is preloading the Wikiwand page for 高阶函数.

高阶函数

此條目没有列出任何参考或来源。 (2019年3月6日)維基百科所有的內容都應該可供查證。请协助補充可靠来源改善这篇条目。无法查证的內容可能會因為異議提出而被移除。

数学计算机科学中,高阶函数是至少满足下列一个条件的函数

  • 接受一个或多个函数作为输入
  • 输出一个函数

在数学中它们也叫做算子(运算符)或泛函微积分中的导数就是常见的例子,因为它映射一个函数到另一个函数。

无类型lambda演算,所有函数都是高阶的;在有类型lambda演算[註 1]中,高阶函数一般是那些函數型別包含多于一个箭头的函数。在函数式编程中,返回另一个函数的高阶函数被称为Curry化的函数。

一般性例子

[编辑]

在很多函数式编程语言中能找到的map函数是高阶函数的一个例子。它接受一个函数f作为参数,并返回接受一个列表并应用f到它的每个元素的一个函数。高阶函数的其他例子包括:

範例

[编辑]

這是一個Python 脚本语言的例子,其中函式g()有一引數以及回傳一函數.這個例子會列印100 ( g(f,7)= (7+3)×(7+3) ).

def f(x):
    return x + 3

def g(function, x):
    return function(x) * function(x)

print g(f, 7)

下列是Scheme語言的例子,函數g()有一引數以及回傳一函數。函數a()取得一值並加上7,再回傳,(例如a(3)=10)。

(define(g x)
  (lambda (y) (+ x y)))
(define a (g 7))
(display (a 3))

注释

[编辑]
  1. ^ 大多数函数式编程语言都从中演化而来

参见

[编辑]
{{bottomLinkPreText}} {{bottomLinkText}}
高阶函数
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?