Make multiply great again

This commit is contained in:
Diogo Cordeiro 2018-12-20 01:39:11 +00:00
parent 957e484db5
commit 2057d2b14f

View File

@ -210,7 +210,13 @@ do_process_input(simplify(PT)) :-
do_process_input(multiply(TN, PT)) :-
polynomial_tree_to_polynomial(TN, N),
polynomial_tree_to_polynomial(PT, P),
scalepoly(N, P, P2),
(
not(number(N)),
scalepoly(N, P, P2)
;
number(N),
scalepoly(P, N, P2)
),
simpoly(P2, SP),
write(SP),
nl.
@ -552,7 +558,7 @@ parse_command(simplify(T)) -->
parse_polynomial(T).
parse_command(multiply(TN, TP)) -->
[multiply],
parse_number(TN),
parse_polynomial(TN),
[by],
parse_polynomial(TP).
parse_command(op(-, TN, TP)) -->