I have a function that is very expensive to compute,
fun(x). But I might be calling it on the same argument multiple times. Therefore it would be helpful if the function was able to store somehwere the result it obtained for a given value of
x, instead of having to compute it again when it is called with the same value of
x twice or more.
What is the best way to achieve this?