liveBook · Manning

Pure function

A pure function is a function whose output is determined solely by its explicit inputs and whose evaluation has no externally observable side effects.

How 19 Manning books explain it

The Joy of JavaScript

How it is used
Uses pure functions to express predictable business logic as composable transformations while separating necessary application effects.
How deep it goes
Defines purity and referential transparency, then works through dependency exposure, decomposition, composition, and practical effect boundaries.
Examples
Uses array filtering and reduction, transaction hashing, wallet-balance calculation, and file word counting as concrete cases.
What you can do after
Practice/perform refactoring that exposes hidden dependencies, composes pure calculations, and isolates effectful work.

Read how The Joy of JavaScript explains pure function →

Functional Programming in JavaScript

How it is used
Uses pure functions to reduce shared-state complexity in functional JavaScript programs.
How deep it goes
Explains purity through stateful counter and student-display refactorings, then connects it to decomposition and composition.
Examples
Contrasts counter increment, array squaring, average calculation, and student-display code that reads data and updates the DOM.
What you can do after
Evaluate/understand whether JavaScript logic relies on external state and refactor it into smaller composable functions.

Read how Functional Programming in JavaScript explains pure function →

Functional Programming in Scala, Second Edition

A pure function is a function whose result depends only on its arguments and whose evaluation has no observable side effects.

How it is used
Establishes functional programming’s core discipline and guides refactoring effects into explicit outer layers.
How deep it goes
Defines purity through referential transparency, demonstrates substitution failure, and qualifies the rule with locally scoped mutation.
Examples
Contrasts StringBuilder.append with string reversal, then refactors a player contest and implements local-mutation quicksort.
What you can do after
Apply it by extracting pure computations from effectful procedures and isolating I/O at program boundaries.

Read how Functional Programming in Scala, Second Edition explains pure function →

The Art of Code

A pure function is a function that produces the same result for the same inputs without observable side effects or dependence on external mutable state.

How it is used
Frames predictable transformations as a route to readable, testable functional pipelines.
How deep it goes
Defines referential transparency, contrasts impure effects, and examines subtle mutation through shallow versus deep immutability.
Examples
Uses Java Stream word transformations, mutated counters and Books, plus a Haskell transformation separated from printing.
What you can do after
Evaluate/understand whether a transformation is replaceable by its result and isolate unavoidable side effects explicitly.

Read how The Art of Code explains pure function →

Modern C, Third Edition

A pure function is a function whose interactions with the rest of a program occur only through its interface and whose behavior has no other observable effects.

How it is used
Supports modular small-task functions whose behavior is understandable through arguments and return values and useful for compiler optimization.
How deep it goes
Defines purity by result dependency and effects, lists disqualifying state interactions, and qualifies the C23 annotation for pointer-taking functions.
Examples
Uses value-returning rational-number operations, a pointer-based swap, and floating-point rounding state to test the boundary.
What you can do after
Build it from scratch: write small value-returning functions, check their state dependencies and effects, then annotate qualifying C23 definitions.

Read how Modern C, Third Edition explains pure function →

Build a Frontend Web Framework (From Scratch)

A function that produces the same output for the same inputs and has no observable side effects.

How it is used
Uses pure functions to generate component views from application state and to calculate new state in reducers.
How deep it goes
Defines determinism and side effects, then demonstrates view composition and immutable reducer updates; component-held state is treated separately.
Examples
Shows a to-do list view, a composed application view, and an add-to-do reducer.
What you can do after
Build it from scratch as JavaScript view functions and reducers that return results without changing their inputs.

Read how Build a Frontend Web Framework (From Scratch) explains pure function →

F# in Action: A Revised Edition of Get Programming with F#

Functional purity is the property of functions having deterministic outputs for given inputs and no observable side effects.

How it is used
Models state changes and business logic as explicit input-to-output transformations, keeping external behavior at narrow boundaries.
How deep it goes
Defines purity and side effects, then works through immutable state, testing, caching, and separating output generation from I/O.
Examples
Uses gas consumption state transitions and customer greetings separated from console printing.
What you can do after
Apply it by writing repeatable functions that return values and isolating database, console, and mutable-state work.

Read how F# in Action: A Revised Edition of Get Programming with F# explains pure function →

Functional Design and Architecture: Examples in Haskell

A pure algorithm is an algorithm whose result is determined by its inputs and which produces no observable side effects.

How it is used
Uses pure functions to make functional code predictable while separating calculations from observable effects.
How deep it goes
Defines purity through side effects, mutation, determinism, composition, effect types, and testing practices without formal semantics.
Examples
Uses a `calc` and `max` pipeline, Haskell IO routines, square tests, IORef-dependent tests, and malformed square properties.
What you can do after
Apply it via hspec and QuickCheck to test deterministic algorithms with cases and generated invariants.

Read how Functional Design and Architecture: Examples in Haskell explains pure function →

The Well-Grounded Rubyist, Fourth Edition

A pure function is a computation that produces its result from its inputs without observable side effects or dependence on mutable external state.

How it is used
Uses pure functions to make Ruby computations predictable while contrasting functional style with stateful object behavior.
How deep it goes
Defines purity and referential transparency, then works through mutating and nonmutating Ruby methods; does not pursue the underlying mathematics deeply.
Examples
Contrasts array summation with `shift` and `reduce`, shows arithmetic and `map`, and refactors a grading calculation.
What you can do after
Diagnose/debug with it by checking whether a Ruby method’s result depends only on inputs and whether it changes observable state.

Read how The Well-Grounded Rubyist, Fourth Edition explains pure function →

Modern C

A mathematical function is a C library function that computes a numerical or mathematical result.

How it is used
Uses interface-only functions to improve readability, modularity, and optimization in C code.
How deep it goes
Defines purity, lists disqualifying effects, and explains optimization consequences while deferring local static variables to later treatment.
Examples
Demonstrates rational-number constructors, normalization, scaling, multiplication, and addition as value-returning operations.
What you can do after
Evaluate whether a C function is pure and recognize when its result permits movement or parallel execution.

Read how Modern C explains pure function →

React Quickly, Second Edition

A pure function is a function whose result depends only on its arguments and that has no observable side effects.

How it is used
Uses pure utilities to simplify React functional components and convert class methods that need no component-local information.
How deep it goes
Defines argument dependence and side-effect freedom, then works through React conversion trade-offs without examining implementation internals.
Examples
Demonstrates image-source generation in a gallery and compares external utilities with methods reading component properties.
What you can do after
Apply it by extracting React utilities, passing required properties explicitly, and identifying when a local function is simpler.

Read how React Quickly, Second Edition explains pure function →

Learn Haskell by Example

A pure function is a function whose result depends only on its inputs and that produces no observable side effects.

How it is used
Separates deterministic transformations from operating-system interaction in command-line tools.
How deep it goes
Explains the pure-versus-IO boundary through program tasks and testing rationale, without detailing compilation behavior.
Examples
Uses an uppercase line reader and a file line-numbering tool with parsing, filtering, formatting, and printing tasks.
What you can do after
Apply it via IO actions by keeping input, file access, and output impure while transforming data with pure functions.

Read how Learn Haskell by Example explains pure function →

Write Powerful Rust Macros

A pure function is a function with no observable side effects whose result depends only on its input parameters.

How it is used
Uses pure functions to isolate transformations and business logic, improving reasoning and testing while containing interactions with external systems.
How deep it goes
Defines determinism and side effects, contrasts database access, and applies the distinction to testing and code organization.
Examples
Demonstrates fixed-threshold summation and contrasts it with summation governed by a database query.
What you can do after
Apply pure functions to write deterministic business logic that can be tested without mocking external dependencies.

Read how Write Powerful Rust Macros explains pure function →

Deep Learning with R, Third Edition

A pure function produces results solely from its explicit inputs and has no externally observable side effects.

How it is used
Uses explicit inputs instead of hidden global state to make computations repeatable and compatible with stateless execution.
How deep it goes
Explains repeatability through random keys and seed management, while stopping short of a general side-effect taxonomy.
Examples
Demonstrates R noise generation with explicit seeds and JAX normal sampling with repeated and split PRNG keys.
What you can do after
Apply it via explicit seeds or JAX PRNG keys to reproduce random computations and manage new random states deterministically.

Read how Deep Learning with R, Third Edition explains pure function →

React in Depth

A pure function produces the same return value for the same inputs and has no dependence on external state, randomness, or side effects.

How it is used
Keeps React renders and lifecycle-related functions safe to rerun during scheduling, Strict Mode checks, and future component reactivation.
How deep it goes
Defines input dependence and outside effects, then demonstrates failures under Strict Mode without developing a general purity formalism.
Examples
Uses an external counter, repeated initializers, effect-driven state updates, cleanup logs, and memoized addition.
What you can do after
Diagnose rerun bugs and choose memoization only when a function’s output depends solely on its inputs.

Read how React in Depth explains pure function →

Fabulous Adventures in Data Structures and Algorithms

A pure function is a function whose result depends only on its input values and that has no observable interaction with global state.

How it is used
Uses purity to justify memoization and eliminate repeated computation in immutable data structures and algorithms.
How deep it goes
Defines purity, demonstrates a generic memoizer, and measures cache behavior without detailing a formal effect system.
Examples
Uses a C# memoizer, immutable quadtrees, HashLife's Step method, and memoized term-processing operations.
What you can do after
Apply it via memoization by identifying repeatable inputs, caching results, and monitoring or clearing cache growth.

Read how Fabulous Adventures in Data Structures and Algorithms explains pure function →

Clojure: The Essential Reference

A pure function produces the same result for the same arguments and has no observable side effects.

How it is used
Guides function design toward predictable results and controlled side effects, especially when composing or memoizing functions.
How deep it goes
Defines repeatable results and absent observable effects, then explains referential transparency without descending into implementation internals.
Examples
Uses memoized Levenshtein distance and contrasts predictable pure output with repeatedly-generated random values and side-effecting workers.
What you can do after
Apply memoize safely when function results depend only on arguments and recognize when repeated calls require fresh effects.

Read how Clojure: The Essential Reference explains pure function →

100 Java Mistakes and How to Avoid Them

A stateless function computes each result without depending on mutable state or other invocations of the function.

How it is used
Enforces stateless functions in Stream API operations, especially utilities that must remain safe when callers request parallel execution.
How deep it goes
Explains state retention, encounter-order assumptions, and parallel failure, but stops short of implementing a general pairwise operation.
Examples
Uses a pairMap utility that combines adjacent strings and a stateful Function storing the previous element.
What you can do after
Diagnose stateful stream operations, test utilities with parallel(), and choose StreamEx or a non-Stream solution when appropriate.

Read how 100 Java Mistakes and How to Avoid Them explains pure function →

Kotlin in Action, 2E

How it is used
Uses pure functions to support Kotlin’s functional style alongside object-oriented programming.
How deep it goes
Defines deterministic results and absence of side effects, then connects purity to concurrency, testing, and reasoning.
Examples
Shows a collection pipeline and contrasts concise lambda syntax with a button handler that produces observable output.
What you can do after
Evaluate/understand whether functions are repeatable, isolated, and free from observable interaction with surrounding state.

Read how Kotlin in Action, 2E explains pure function →

Related concepts

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.