-
-
Notifications
You must be signed in to change notification settings - Fork 443
Open
Description
Description:
Implement a memoization utility that caches results of a function to avoid repeated computation. The snippet should use a Map to store input/output pairs.
The snippet should accept a Function<T, R> and return a memoized version of the same function. Internally, it should use a thread-safe cache (e.g., ConcurrentHashMap) to store the input/output mapping.
This utility is particularly useful in functional programming contexts, or when building services that rely on frequently repeated expensive computations.
Acceptance Criteria:
- A new memoization snippet has been added
- Method Function<T, R> memoize(Function<T, R>) is provided.
- Demonstrate/test usage with a recursive Fibonacci function.
- Cache is used to optimize repeated calls.
Metadata
Metadata
Assignees
Projects
Status
Todo