21 Oct
2018
21 Oct
'18
12:33 p.m.
Wheres a lambda expression can be passed anonymously to any other function as an argument.
map(lambda x: x**2, array)
vs
def powers2(x) x**2 map(powers2, array)
Coming up with a name here is not needed, as the operation is expressive enough.
Sure, but there is a well known convention for such non-names already: meta syntactical variables. In this case the name could be "foo" and all readers will interpret this as "no name". I admit to have wanted lambdas that are just as powerful as normal functions, but often when I want it the code is nicer when a normal function is used. / Anders