Make addition great again
This commit is contained in:
parent
3daaee65a5
commit
4264649271
25
polymani.pl
25
polymani.pl
@ -117,7 +117,6 @@ process_input(command(CL, void)) :-
|
|||||||
%% Process only command left
|
%% Process only command left
|
||||||
do_process_input(CL).
|
do_process_input(CL).
|
||||||
|
|
||||||
|
|
||||||
%% do_process_input(+tree) is det
|
%% do_process_input(+tree) is det
|
||||||
%
|
%
|
||||||
% Process a single command from the input
|
% Process a single command from the input
|
||||||
@ -288,6 +287,22 @@ do_process_input(multiply(TN, PT)) :-
|
|||||||
),
|
),
|
||||||
simpoly(P2, SP),
|
simpoly(P2, SP),
|
||||||
writeln(SP).
|
writeln(SP).
|
||||||
|
do_process_input(op(+, TN, PT)) :-
|
||||||
|
polynomial_tree_to_polynomial(TN, N),
|
||||||
|
polynomial_tree_to_polynomial(PT, P),
|
||||||
|
addpoly(N, P, P2),
|
||||||
|
simpoly(P2, SP),
|
||||||
|
writeln(SP).
|
||||||
|
do_process_input(store_addition(TN, PT, V)) :-
|
||||||
|
polynomial_tree_to_polynomial(TN, N),
|
||||||
|
polynomial_tree_to_polynomial(PT, P),
|
||||||
|
addpoly(N, P, P2),
|
||||||
|
simpoly(P2, SP),
|
||||||
|
assertz(polynomial_store(V, SP)),
|
||||||
|
write(V),
|
||||||
|
write(" = "),
|
||||||
|
write(SP),
|
||||||
|
nl.
|
||||||
|
|
||||||
%% print_all_stored_variables
|
%% print_all_stored_variables
|
||||||
%
|
%
|
||||||
@ -780,6 +795,14 @@ parse_command(op(-, TN, TP)) -->
|
|||||||
[X],
|
[X],
|
||||||
{ member(X, [to, from, with]) },
|
{ member(X, [to, from, with]) },
|
||||||
parse_polynomial(TP).
|
parse_polynomial(TP).
|
||||||
|
parse_command(store_addition(TN, TP, V)) -->
|
||||||
|
[add],
|
||||||
|
parse_polynomial(TN),
|
||||||
|
[X],
|
||||||
|
{ member(X, [to, with]) },
|
||||||
|
parse_polynomial(TP),
|
||||||
|
[as],
|
||||||
|
[V].
|
||||||
parse_command(op(+, TN, TP)) -->
|
parse_command(op(+, TN, TP)) -->
|
||||||
[add],
|
[add],
|
||||||
parse_polynomial(TN),
|
parse_polynomial(TN),
|
||||||
|
Reference in New Issue
Block a user