What is a lambda (function)?

后端 未结 23 2287
太阳男子
太阳男子 2020-11-22 04:47

For a person without a comp-sci background, what is a lambda in the world of Computer Science?

23条回答
  •  忘了有多久
    2020-11-22 05:01

    It is a function that has no name. For e.g. in c# you can use

    numberCollection.GetMatchingItems(number => number > 5);
    

    to return the numbers that are greater than 5.

    number => number > 5
    

    is the lambda part here. It represents a function which takes a parameter (number) and returns a boolean value (number > 5). GetMatchingItems method uses this lambda on all the items in the collection and returns the matching items.

提交回复
热议问题