functions that memorize

*To*: mathgroup at smc.vnet.net*Subject*: [mg18402] functions that memorize*From*: hanssen at zeiss.de*Date*: Wed, 7 Jul 1999 00:11:03 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Hi, MathGroup, for functions, which cost much time to compute, it is handy, to let them memorize, for which arguments they were already computed. The prototype for doing this is f[x_]:=f[x]=rhs In a lengthy computation, I want to memorize partial results (of n parameters, n fixed) I can do this f[1,2]=rhs1 f[3,4]=rhs2 Now my case is a bit more general, the partial result only depends on the first n elements of a list "pv". This does not work for n=2 and pv={99,99,...} f@@Take[pv,n] = rhs it complains about "Set::write: Tag Apply in ab @@ ({99, 99}) is Protected". However, f[99,99]=3 works. Lateron I can inquire f@@Take[pv,n] and get back 3, as expected. Any idea, how to make the assignment with the symbols on the left side - I have tried Hold etc without success. kind regards Dipl.-Math. Adalbert Hanszen