Added simplify instruction
Refactored print_polynomial to print_polynomial_tree nl instead of write(\n)
This commit is contained in:
parent
240b480aae
commit
a6c2073209
35
polymani.pl
35
polymani.pl
@ -73,31 +73,44 @@ process_input(show(P, void)) :-
|
|||||||
polynomial_store(P, T),
|
polynomial_store(P, T),
|
||||||
write(P),
|
write(P),
|
||||||
write(" = "),
|
write(" = "),
|
||||||
print_polynomial(T),
|
print_polynomial_tree(T),
|
||||||
write("\n").
|
nl.
|
||||||
process_input(show(P, T)) :-
|
process_input(show(P, T)) :-
|
||||||
P \== void,
|
P \== void,
|
||||||
T \== void,
|
T \== void,
|
||||||
write(P),
|
write(P),
|
||||||
write(" = "),
|
write(" = "),
|
||||||
print_polynomial(T),
|
print_polynomial_tree(T),
|
||||||
write("\n").
|
nl.
|
||||||
process_input(show(void, T)) :-
|
process_input(show(void, T)) :-
|
||||||
T \== void,
|
T \== void,
|
||||||
print_polynomial(T),
|
print_polynomial_tree(T),
|
||||||
write("\n").
|
nl.
|
||||||
process_input(store(P, T)) :-
|
process_input(store(P, T)) :-
|
||||||
assertz(polynomial_store(P, T)),
|
assertz(polynomial_store(P, T)),
|
||||||
write("\n").
|
nl.
|
||||||
|
process_input(simplify(P)) :-
|
||||||
|
polynomial_tree_to_polynomial(P, PP),
|
||||||
|
simpoly(PP, SP),
|
||||||
|
write(SP),
|
||||||
|
nl.
|
||||||
|
|
||||||
|
print_polynomial_tree(op(Op, TL, TR)) :-
|
||||||
print_polynomial(op(Op, TL, TR)) :-
|
|
||||||
write(TL),
|
write(TL),
|
||||||
write(Op),
|
write(Op),
|
||||||
print_polynomial(TR).
|
print_polynomial_tree(TR).
|
||||||
print_polynomial(T) :-
|
print_polynomial_tree(T) :-
|
||||||
write(T).
|
write(T).
|
||||||
|
|
||||||
|
polynomial_tree_to_polynomial(op(Op, TL, TR), P) :-
|
||||||
|
polynomial_tree_to_polynomial(TL,A),
|
||||||
|
polynomial_tree_to_polynomial(TR,B),
|
||||||
|
atom_concat(A, Op, AOp),
|
||||||
|
atom_concat(AOp, B, Pa),
|
||||||
|
term_to_atom(P,Pa),
|
||||||
|
!.
|
||||||
|
polynomial_tree_to_polynomial(A,A).
|
||||||
|
|
||||||
%% nlp_number(?W:Atom, ?D:Int) is det
|
%% nlp_number(?W:Atom, ?D:Int) is det
|
||||||
%
|
%
|
||||||
% Definition of a Alphabetical and Numerical relation
|
% Definition of a Alphabetical and Numerical relation
|
||||||
|
Reference in New Issue
Block a user