Reusing Pure Calculations by Memoization
A pure computation with stable input representations can reuse a stored result for equivalent arguments.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Trace two repeated calls
A multiplication helper called for 6 and 7 can store 42 for that pair and use it again. A call for 7 and 6 matches only if the chosen key normalizes the symmetric arguments. Cache key design describes that choice.
Check mutable inputs and outputs
A result list returned by reference can be mutated by its first consumer. A later cached result may then differ from a fresh result. See immutable update and snapshots.[1]