What is a lambda (function)?

后端 未结 23 2576
太阳男子
太阳男子 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:05

    It refers to lambda calculus, which is a formal system that just has lambda expressions, which represent a function that takes a function for its sole argument and returns a function. All functions in the lambda calculus are of that type, i.e., λ : λ → λ.

    Lisp used the lambda concept to name its anonymous function literals. This lambda represents a function that takes two arguments, x and y, and returns their product:

    (lambda (x y) (* x y)) 
    

    It can be applied in-line like this (evaluates to 50):

    ((lambda (x y) (* x y)) 5 10)
    

提交回复
热议问题