Memoization - remembering past results

Memoization is the art of computer program optimization to speed up functions. Donald Michie coined the word memoization. Whenever, a memoized function is called for the first time, for a given input, its output value is calculated and cached. Next time when the same input is given as an argument, function does not compute the value but returns the value from cached location for that given input. In some programming language, we find some or other internal mechanism to implement memoization. But many programming languages require explicit work to implement memoization.

So, is it possible that a function can return different output for the same input? The answer is: this is possible. We can understand this ...

Get Learning Functional Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.