python basis - Functional Programming

# Procedure for 
# functional programming: functional programming language defined functions = + function in the mathematical sense 
# object-oriented 



# higher-order functions: 1 function accepts a parameter is the name of the function return value contains functions 2. 

# DEF foo (n-): # = n-bar 
#      Print (n-) 
# 
# DEF bar (name): 
#      Print ( '% S My name IS' name%) 
# 
# 
# foo (bar) # argument to the function as a additional function 
# foo (bar ( 'Tang')) 

# foo (None) 


# which contains the function returns the value 
DEF bar ():
     Print ( ' from bar ' ) 


DEF foo ():
     Print ( " from foo " )
    return bar 

n- = foo () 
n-() 


DEF handle ():
     Print ( ' from handle ' )
     return handle # return value may be a function may be any function, or may be themselves 
H = handle () 
H ()

 

Guess you like

Origin www.cnblogs.com/tangcode/p/10984110.html