Associativity
Associativity is the property of a binary operation that regrouping its operands does not change the result.
Functional Programming in Scala, Second Edition
The algebraic law stating that regrouping repeated applications of a binary operation does not change the result.
- How it is used
- Supports monoids, folds, and parallel combination by making regrouped combines agree.
- How deep it goes
- Defines the law algebraically, tests it with generated triples, and applies it to folds, monads, and applicatives.
- Examples
- Uses strings, integers, Booleans, lists, generated law tests, function composition, and nested effect pairs.
- What you can do after
- Evaluate/understand whether regrouping preserves a computation and why associative operations enable reusable folds.
Read how Functional Programming in Scala, Second Edition explains associativity →
Clojure: The Essential Reference
Associativity is the property that the grouping of operands does not affect the result of repeatedly applying a binary operation.
- How it is used
- Guides decisions about whether reducers and transducers can safely support parallel folding.
- How deep it goes
- Explains semantic failures through chunked dropping and marks several reducers as non-foldable, without developing a general algebraic definition.
- Examples
- Uses sequential and parallel dropping examples whose sums differ across repeated executions.
- What you can do after
- Diagnose whether a stateful reducer preserves sequential semantics when executed through parallel folding.
Read how Clojure: The Essential Reference explains associativity →
100 Java Mistakes and How to Avoid Them
Associativity is the property that the grouping of operands does not change the result of an operation.
- How it is used
- Constrains accumulator functions supplied to Java Stream.reduce, especially when computation may be parallelized.
- How deep it goes
- Defines regrouping algebraically and demonstrates the failure through a hash-code reduction, stopping short of general algebraic treatment.
- Examples
- Uses List.hashCode, a multiplication-and-addition accumulator, and contrasting sequential and parallel computation orders.
- What you can do after
- Evaluate reduction accumulators against associativity and identity requirements before using them with streams.
Read how 100 Java Mistakes and How to Avoid Them explains associativity →
Learn Haskell by Example
An associative function is a binary operation whose grouping does not affect the result.
- How it is used
- Uses CSV appending to motivate regrouping operations and introduce the Semigroup abstraction.
- How deep it goes
- Defines the equality law, distinguishes grouping from operand order, and notes that the compiler does not verify it.
- Examples
- Uses CSV values, lists, and strings to demonstrate associative combination with <> and mconcat.
- What you can do after
- Build it from scratch by implementing an associative append operation and checking its Semigroup law.
Advanced Algorithms and Data Structures
An associative operation gives the same result regardless of how operands are parenthesized, so regrouping intermediate results does not change the outcome.
- How it is used
- Uses associativity to determine whether grouped intermediate results can be safely combined in parallel reducers.
- How deep it goes
- Defines the operational requirement for reducers but stops short of formal notation or proof.
- Examples
- Uses grouped coin lists, coin counting, and total-value aggregation as reduction examples.
- What you can do after
- Evaluate whether a grouped computation is suitable for parallel reduction.
Read how Advanced Algorithms and Data Structures explains associativity →
Related concepts
- monadused by · A monad is a functional abstraction that encapsulates computational context and provides operations for composing computations while preserving that context.
- reduction operationused by · A reduction operation combines multiple input values or partial results according to a combining rule to produce fewer results, often a single aggregate.
- floating-point arithmeticcontrasts with · Floating-point arithmetic is computation using finite-precision representations of real numbers, which can introduce rounding and range errors.
- applicative functoruses · An applicative functor is an abstraction that applies functions within a computational context to context-wrapped values while combining their contexts.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




