Skip to content
uencoder

Pure Function

A pure function always returns the same output for the same input and has no side effects — the foundation of functional programming and reliable code.

Purpose

Predictable, testable, cacheable functions that eliminate hidden state dependencies.

Mechanism

Conditions: 1) same input → same output (referential transparency); 2) no side effects (no mutating external state, no depending on mutable external state). Enables memoization, parallel execution, and equational reasoning.

Use cases

  • Functional programming
  • Simplified testing
  • Reliable code

Related terms

References