Chapter 3
Immutability
Functional programming is inspired by mathematical functions, which are not contingent on any notion of mutation, or state change, or variable assignment. A functional programming style favors immutable data. Imperative code based on mutation is replaced with programs that combine immutable values into expressions. In particular, series of immutable values are used as a substitute for the mutable data structures typical of imperative programs.
3.1 Pure and Impure Functions
Mathematical functions were characterized earlier as mappings of values from an input set to values in an output set. For instance, an absolute value function maps integers (of any sign) to non-negative natural numbers. Programming language functions ...
Get Functional and Concurrent Programming: Core Concepts and Features now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.