Functional programming is a declarative type of programming style that treats computation as the evaluation of mathematical functions.
Concepts of functional programming
A function is considered to be pure, if
- it returns the same result when given the same arguments
- does not cause any side effects
In functional programming, iteration is performed through recursion and not through while / for loops. The result is achieved by letting an operation be repeated until it reaches the base case.
Higher-order functions are functions that can either take other functions as arguments or return them as results. Higher-order functions are closely related to first-class functions in that higher-order functions and first-class functions both allow functions as arguments and results of other functions.
An immutable object is an object whose state cannot be modified after it is created. In multi-threaded applications, this approach allows for a thread to act on data represented by immutable objects without worrying what other threads are up to.
Write clean and secure code with DeepSource
Powerful static analysis that takes 5 minutes to set up and helps you fix code health and security problems on every pull request.