Bill Allombert on Sat, 25 Mar 2023 23:29:13 +0100


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

Re: from t_POL to t_CLOSURE (and back)


On Sat, Mar 25, 2023 at 05:54:10PM -0400, Max Alekseyev wrote:
> Is there any more straightforward/logical way than the following?
> 
> ? p = x^3 + x + 1
> %1 = x^3 + x + 1
> ? type(p)
> %2 = "t_POL"
> ? f = z -> subst(p,variable(p),z)
> %3 = (z)->subst(p,variable(p),z)
> ? type(f)
> %4 = "t_CLOSURE"
> ? q = f('x)
> %5 = x^3 + x + 1
> ? type(q)
> %6 = "t_POL"

I do not know what is more straightforward/logical, but you can do 

f(x)=eval(p)

Cheers,
Bill