Functional programming in the function f (x) emphasizes the stateless, in fact, the emphasis is to lock the state inside the function, a function that does not depend on any external state, only depends on its entry parameter value, once the value is determined, the function returns the result is OK. Some people may feel that the entry is also the state, is the external incoming state, in fact, I said before the variable will have a state, the value is not state,
Functional programming in the function, can be summed up in a sentence: the isolation of all external states, incoming values, output values.
A pure function is a function that is emphasized by functional programming, and the above two points can be translated as:
- Not dependent on external state
- does not change the external state
So the understanding of functions in functional programming is finally carried out to the understanding of state. The state of stillness is safe, the state of change is dangerous, and the danger can be understood from two dimensions, time and space.
Turn: iOS and functional programming