Reputation: 27
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
Upvotes: 0
Views: 223
Reputation: 363547
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.
Upvotes: 3