Use lambda to define simple function : lambda function : Function : Python examples (example source code) Organized by topic

C++
PHP
Python
Python Home »  Function   » [  lambda function  ]  Screenshots 
 



Use lambda to define simple function




def make_incrementor (n)return lambda x: x + n
 
f = make_incrementor(2)
g = make_incrementor(6)
 
print f(42), g(42)

 
print make_incrementor(22)(33)



           
       
Related examples in the same category
1.  lambda function definition with default value lambda function definition with default value
2.  Define function in Lambda Forms Define function in Lambda Forms
3.  Difference between a normal function and a lambda function Difference between a normal function and a lambda function
4.  Define lambda function inside another function Define lambda function inside another function
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.