Been messing around with functional programming concepts and came across memoization.
Here's an example:
public static Func<T, TResult> Memoize<T, TResult>(this Func<T, TResult> f) {
var cache = new ConcurrentDictionary<T, TResult>();
return a => cache.GetOrAdd(a, f);
}
How does the returned function still have access to the dictionary object?