Functional programming is a very high degree of abstraction of the programming paradigm, the purely functional programming language functions are not variable, so any function, as long as the input is determined, the output is OK, this pure function we call no side effects. In the case of programming languages that allow the use of variables, because of the variable state inside the function, the same input may get different output, so this function has side effects.
One of the features of functional programming is that it allows the function itself to be passed as a parameter to another function, and also allows a function to be returned!
Python provides partial support for functional programming. Because Python allows the use of variables, Python is not a purely functional programming language.
Higher order function: One function can receive another function as a parameter
A variable can point to a function, and the function itself can be assigned to a variable, and the function name is also a variable
Such as:
In []: absout[]: <function abs> in[+]: ABS ( -20) out[]:[+]: x = Absin [+]: X ( -2) out[23]: 2
Incoming function
def sum (x, y): ....: return x+yIn [def de (x, y): ... ..: return xy ....: in [def Cal (X,y,sum,de): .... : return sum (x, y) *de (x, y) .... : In []: cal (2,5, sum,de) out[28]: 21
Python-Functional programming