I am trying to run a recursive definition while at the same time clearing previously found values, so my memory is not completely consumed. I found this: How to clear parts of a memoized function? But it does not seem to be what I am looking for. I want to clear memorized values, while the recursion is running. I thought I could do something like this:
Block[{$IterationLimit = $RecursionLimit = ∞},f [m_]:= f [m] = f [m-1]+f [m-2]
f[0]=0
f[1]=1
If [m - 3 > 0, Unset[f[m-3]]]
But it does not work. I realize I could just use Fibonacci[n]
, but I am doing this to try to learn Mathematica not to study the Fibonacci sequence. Thank you for any help!
Comments
Post a Comment