+ 2

Is "lamda" a function or what?

31st Mar 2017, 4:06 PM
Spider
Spider - avatar
4 ответов
+ 9
Technically its a group of functions that are created when the program is being run. They are called lambda functions. So to answer your question, lambda is a contruct to create funtions..
31st Mar 2017, 4:16 PM
Wen Qin
Wen Qin - avatar
+ 4
In some sense, but you should not think about it that way. It is an expression, which allows you to create a function myfunc = lambda parameters: expressions instead of using the whole def myfunc(parameters): expression way of defining it. You don't even have to name it (like when you pass it as an argument to map() ). If you really want, you can view it as a "function", which yields function objects, though. Hope that helps, if you have questions, fire away.
31st Mar 2017, 4:31 PM
Tob
Tob - avatar
+ 2
Kinda .. more like a construct that allows you to create an ad-hoc anonymous function .. you could think of lambdas as the ternary operator is vs. a normal "if/else" conditional structure, it saves time, is one-line-elegant statement, you create it where you use it. Maybe i've stretched it a little but this is how i see it, same as i see list comprehensions as compared to "for each" constructs
31st Mar 2017, 4:56 PM
Eduard Alexandru
Eduard Alexandru - avatar
0
lambda should actually be called "make_function" in the words of a Python core developer. But it is called lambda for historic reasons, and once it's here, it sticks pretty much forever...
31st Mar 2017, 9:18 PM
Amaras A
Amaras A - avatar