What is a lambda and what is an example implementation?

后端 未结 6 900
轮回少年
轮回少年 2020-12-30 15:43

I am fairly new to programming and while doing a lot of reading this concept of a lambda keeps coming up but I\'m having a hard time putting my finger on what it actually is

6条回答
  •  醉酒成梦
    2020-12-30 16:20

    Lambda means different things to different languages. I know about them in the context of python, but I've heard that python has a different approach than other languages.

    Essentially, in python, a lambda is an anonymous function that can only consist of a single expression, the result of which is returned.

    I understand that in other languages, they are more generalized anonymous functions, without the single expression limitation, but I'm not certain about the details.

    An anonymous function, is just what it sounds like. A function without a name. For example, they are frequently used as event handlers, or any case in which you need a simple callback function, but don't want to clutter up the namespace.

提交回复
热议问题