首页 > 其他 > 详细

lambda表达式、匿名函数

时间:2018-06-05 19:09:13      阅读:236      评论:0      收藏:0      [点我收藏+]

lambda表达式是函数式编程中的匿名函数语法规范。

 

In computer programming, an anonymous function (function literallambda abstraction, or lambda expression) is a function definition that is not bound to an identifier. Anonymous functions are often:[1]

  • arguments being passed to higher-order functions, or
  • used for constructing the result of a higher-order function that needs to return a function.

If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in functional programming languages and other languages with first-class functions, where they fulfill the same role for the function type as literals do for other data types.

Anonymous functions originate in the work of Alonzo Church in his invention of the lambda calculus in 1936, before electronic computers, in which all functions are anonymous.[2]

 

 

Anonymous functions can be used for containing functionality that need not be named and possibly for short-term use. Some notable examples include closures and currying.

Use of anonymous functions is a matter of style. Using them is never the only way to solve a problem; each anonymous function could instead be defined as a named function and called by name. Some programmers use anonymous functions to encapsulate specific, non-reusable code without littering the code with a lot of little one-line normal functions.

 

https://en.wikipedia.org/wiki/Anonymous_function#C.23_lambda_expressions

lambda表达式、匿名函数

原文:https://www.cnblogs.com/feng9exe/p/9141310.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!