Use this for simple functions and un-parameterised methods
Use this for simple functions and un-parameterised methods
BEWARE - uses the function as a key to locate the memoised cache. Does not work when the functions are created on the fly, as each is a different instance.
As per memo with a key, except the function is used as the key. Does NOT work for methods which assign the function on the fly - use an explicit key via the other memo method, instead.
the input parameter type of function f
the output type of function f
the function to memoise
a Cache[I, O]
Use this for parameterised methods, or anywhere else you can't use the function as a key.
Use this for parameterised methods, or anywhere else you can't use the function as a key. In all other cases, the simpler memo() method, below, is probably better.
val f = method _ def memoised(input: String) = memo ("allTheThings") { f } (input)