memo1<A, R> function

R Function(A) memo1<A, R>(
  1. R f(
    1. A
    )
)

memo-ize the given function, caching the return result.

Implementation

R Function(A) memo1<A, R>(R Function(A) f) {
  final cache = HashMap<A, R>();
  return (A a) => cache.putIfAbsent(a, () => f(a));
}