Bill Allombert on Tue, 29 Jun 2004 16:14:54 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Functions


On Tue, Jun 22, 2004 at 08:00:56PM +0100, Jon Perry wrote:
> If f(x)=x^2, then the line
> 
> f(x)+=x
> 
> to give f(x)=x^2+x
> 
> doesn't work.

In retrospect, I wonder if what you are looking for is not subst():
? P=x^2;
? f(x)=subst(P,'x,x)
? f(2)
%2 = 4
? P+=x;
? f(2)
%4 = 6

Cheers,
Bill