Re: Computing dynamic functions
- To: mathgroup@smc.vnet.net
- Subject: [mg11586] Re: Computing dynamic functions
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Tue, 17 Mar 1998 10:43:07 -0500
In a private response to my earlier posting Gabriel Alvarez writes > What I do not know how to do is to type > > ``Something with h's, x_, := ... and Expand[(1+x)^2]'' > > and get > > h[x_]:= h[x] = 1 + 2 x + x^2 The following does this In[1]:= remember[ h_,x_,g_]:= (h[x_]:=h[x] = g) RuleDelayed::"rhs": "Pattern \!\(x_\) appears on the right-hand side of rule \ \!\(\(remember[\(h_, x_, g_\)]\) \\[RuleDelayed] \(\(h[x_]\) := \(\(h[x]\) = \ g\)\)\)." We can ignore the message. In[2]:= remember[h,x,Expand[(1+x)^2]] In[3]:= ?h "Global`h" h[x_] := h[x] = 1 + 2*x + x^2 Some use of holding attributes would change the behaviour -- Allan Hayes Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642