The # higher order function # variable can point to the function # the Python built-in absolute value of the function abs () For example, call the function with the following code print (ABS ( -10)) # write abs# output as:< Built-in function abs>print (ABS) # abs (-10) is a function call, and ABS is the function itself # to get the result of a function call, we can assign the result to the variable X = abs ( -10) print (x) # assigns the function itself to the variable f = absprint (f) The # function itself can also assign a value to the variable, that is, the variable can point to the function # If a variable points to a function, the function can be called by a variable f = absprint (f ( -10)) # -------------------------------------------- ----------------# function name is also a variable # function name is actually a variable that points to the function # for abs () This function, it is possible to think of ABS as a variable, it points to a function that can calculate the absolute value # If the ABS points to other objects in the call, the system will error: typeerror: ' int ' object is not callable # abs = 10# print (ABS ( -10)) # because the ABS function is actually defined in the Import builtins module, So to modify the point of the ABS variable is also effective in other modules, to use import builtins; builtins.abs=10# ------------------------------------ ------------------------# incoming function # since the variable can point to a function, the function's arguments can receive the variable, then one function can receive another function as a parameter, which is called the higher order function # One of the simplest high-order functions Def add (X,&NBSP;Y,&NBSP;F): &Nbsp; return f (x) + f (y) print (' Add ( -5, 6, abs): ', add ( -5, 6, abs)) # write higher-order functions, that is, to allow the function's parameters to receive other functions # the function as a parameter, such a function is called higher-order function, functional programming refers to this highly abstract programming paradigm
Python---higher-order functions