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),
|
||||
write(P),
|
||||
write(" = "),
|
||||
print_polynomial(T),
|
||||
write("\n").
|
||||
print_polynomial_tree(T),
|
||||
nl.
|
||||
process_input(show(P, T)) :-
|
||||
P \== void,
|
||||
T \== void,
|
||||
write(P),
|
||||
write(" = "),
|
||||
print_polynomial(T),
|
||||
write("\n").
|
||||
print_polynomial_tree(T),
|
||||
nl.
|
||||
process_input(show(void, T)) :-
|
||||
T \== void,
|
||||
print_polynomial(T),
|
||||
write("\n").
|
||||
print_polynomial_tree(T),
|
||||
nl.
|
||||
process_input(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(op(Op, TL, TR)) :-
|
||||
print_polynomial_tree(op(Op, TL, TR)) :-
|
||||
write(TL),
|
||||
write(Op),
|
||||
print_polynomial(TR).
|
||||
print_polynomial(T) :-
|
||||
print_polynomial_tree(TR).
|
||||
print_polynomial_tree(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
|
||||
%
|
||||
% Definition of a Alphabetical and Numerical relation
|
||||
|
Reference in New Issue
Block a user