Say I have a function with a few definitions that also implements memoization:
f[x_] := f[x] = x^2
f[x_, y_] := f[x, y] = x^2 + y^2
I then apply the function to some data:
f /@ {1, 2, 3}
f @@@ {{1, 2}, {3, 4}}
Now the function will have a bunch of DownValues
both for the stored results and for the pattern based definitions. Is there some easy way to retrieve only all the stored result, leaving out the pattern based definitions?
Cases[DownValues[f], (_[Verbatim[f][value : Except[_Pattern]]] :> result_) :> (value -> result)]
(general note: i figure this out by usingFullForm
. e.g.FullForm[x_] => Pattern[x, Blank[]]
) $\endgroup$