lambda anonymous function

# lambda x:x+1 #x is the formal parameter is the return value

# lambda function executes 
func = lambda x:x+1
 print (func(1 ))



f = lambda x,y,z:(x+1,y+1,z+1)
print(f(1,2,3))
#
#Programming methodology: 
# Process-oriented: It can be said to solve a big problem into N small problems to deal with, each small problem is a process 
# For example: 
#      y = 2*x+1 
# Process-oriented to solve the above mathematical function The method is; split the big problem into small problems and solve them one by one: 
#      def calc(x): 
#          ret = 2*x 
#          ret = ret + 1 
#          return ret
#
#
#Functional : function defined by programming language + function of mathematical meaning; that is to say, mathematical function is implemented in programming language (python is not strictly functional programming language) 
#For example: 
#      y = 2*x+1 
#Functional programming solution The math function method above is: 
#      def calc(x): 
#          ret = 2*x+1 
#          return ret

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325021575&siteId=291194637