Fix polynomial_tree_to_polynomial

This commit is contained in:
Diogo Cordeiro 2018-12-17 20:29:00 +00:00
parent a6c2073209
commit b984b0efd4

View File

@ -102,14 +102,17 @@ print_polynomial_tree(op(Op, TL, 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),
polynomial_tree_to_polynomial(A,B) :-
polynomial_tree_to_atomic_polynomial(A,Pa),
term_to_atom(B, Pa).
polynomial_tree_to_atomic_polynomial(op(Op, TL, TR), P) :-
polynomial_tree_to_atomic_polynomial(TL,A),
polynomial_tree_to_atomic_polynomial(TR,B),
atom_concat(A, Op, AOp),
atom_concat(AOp, B, Pa),
term_to_atom(P,Pa),
atom_concat(AOp, B, P),
!.
polynomial_tree_to_polynomial(A,A).
polynomial_tree_to_atomic_polynomial(A,A).
%% nlp_number(?W:Atom, ?D:Int) is det
%