Consider the following code:
f[x_]:= SomeCodeAbout[x]
g[x_]:= f[x]
It links g with f, namely when g is called, f runs, and so will SomeCodeAbout[x]. However, if I want just to store the result of f[x], which could be some simple expression after running the SomeCodeAbout[x], into g[x], what should I do (without manually copying the result and defining g)? The reason is simple, since SomeCodeAbout[x] could take a long time to run which is inefficient especially when g is used frequently.
f[x_] = …to evaluate the right side when defining the function instead of delaying it – Lukas Lang Nov 29 '20 at 15:07fusef[x_] := f[x] = SomeCodeAbout[x];– Bob Hanlon Nov 29 '20 at 18:11