Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

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



  • Prev by Date: Re: Re: easiest way to sort a list?
  • Next by Date: Polar coordinates
  • Previous by thread: Re: "At long last, Sir, have you no shame?"
  • Next by thread: Polar coordinates