码迷,mamicode.com
首页 > 其他好文 > 详细

lambda表达式、匿名函数

时间:2018-06-05 19:12:35      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:only   compute   Matter   his   cap   number   possibly   UNC   sam   

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表达式、匿名函数

标签:only   compute   Matter   his   cap   number   possibly   UNC   sam   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!