What Is Memoization?
Memoization is an optimization that stores the output of a pure function keyed by its arguments and returns the cached result when the same inputs recur. The expensive computation runs once per distinct input rather than on every call. It relies on the function being deterministic and free of side effects.
Why it matters
Memoization turns repeated expensive computations into cheap lookups, which is dramatic for overlapping recursive work. The cost is memory for the cache and the assumption that inputs map stably to outputs.
Related guides
What Is Lazy Evaluation?Lazy evaluation delays computing an expression until its value is actually needed, and may skip it entirely i…
What Is a Higher-Order Function?A higher-order function takes other functions as arguments or returns a function as its result, treating beha…
What Is a Thunk?A thunk is a deferred computation wrapped as a value, evaluated only when forced, often used to implement laz…