Purity
One of the pillars of functional programming is pure functions. A pure programming function is a function that is analogous of a mathematical function. It depends only on its input parameters and its internal algorithm and always returns an expected result for a given input, since it doesn't rely on anything from outside. (This is a big difference compared to the OOP methods.) You can easily understand that this makes a function easier to test and maintain. The fact that a pure function doesn't rely on anything else from the outside means that it doesn't have side effects.
Purely functional programs work on immutable data. Rather than altering existing values, altered copies are created while the originals are preserved. This means ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access