Polynomial multiplication in Prolog

497 Views Asked by At

I tried to write a predicate that performs the multiplication of two polynomials, but work only when it receives only monomials. This is the code: Code Monomial + Polinomial , Code Multiplication

Answer:

1 ?- polytimes(2*a*c,4*b*e,A).
A = poly([m(8, 4, [v(1, a), v(1, c), v(1, b), v(1, e)])]).

2 ?- polytimes(3*a*c,2*b,A).
A = poly([m(6, 3, [v(1, a), v(1, c), v(1, b)])]).

3 ?- polytimes(2*a + z,4*b*e,A).
A = poly([m(8, 4, [v(1, a), v(1, z), v(1, b), v(1, e)])]).

I want to know if you had any help about it.

0

There are 0 best solutions below