Question

I have a problem, I need to compact a derivative result like this:

0*x*x + 2*(1*x + x*1) =====> example: 0+2*(2*x) =====> 0+2*4*x====>8*x

Is it possible? Thanks for your help.

Regards, Volter

Était-ce utile?

La solution

Yes, this is possible, it just takes some work. You'll need to write out atomic rules such as

rule(0*_, 0).
rule(_*0, 0).
rule(1*X, X).
rule(X*1, X).

and implement a fixpoint predicate (maybe a failure-driven loop) that applies rules until convergence.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top