Swift adopts some patterns from the functional programming paradigm. It is difficult to provide a concrete definition of functional programming because people use the phrase with different meanings and intentions, but typically it is understood to include:
First-class functions – functions can be returned from and passed as arguments to other functions, can be stored in variables, etc.; they are just like any other type.
Pure functions – functions have no side effects; functions, given the same input, always return the same output and do not modify other states elsewhere in the program. Most math functions like sin, cos, fibonacci, and factorial are pure.
Immutability – mutability is de-emphasized ...