Define function in Lambda Forms : lambda function « Function « Python






Define function in Lambda Forms

Define function in Lambda Forms


# With the lambda keyword, small anonymous functions can be created. 


def make_incrementor(n):
     return lambda x: x + n

f = make_incrementor(42)

print f(0)

print f(1)


           
       








Related examples in the same category

1.lambda function definition with default valuelambda function definition with default value
2.Difference between a normal function and a lambda functionDifference between a normal function and a lambda function
3.Use lambda to define simple functionUse lambda to define simple function
4.Define lambda function inside another functionDefine lambda function inside another function