All together now!

This commit is contained in:
Diogo Cordeiro 2018-11-23 00:09:07 +00:00
parent 0aafcc327f
commit 58f5a5562a

View File

@ -14,12 +14,10 @@
* Hugo David Cordeiro Sales
* up201704178@fc.up.pt
*
*********************************************
* Follows 'Coding guidelines for Prolog' *
* https://doi.org/10.1017/S1471068411000391 *
*********************************************
*/
*********************************************/
/* Import the Constraint Logic Programming over Finite Domains library
* Essentially, this library improves the way Prolog deals with integers,
@ -33,10 +31,11 @@
/*******************************
* USER INTERFACE *
*******************************/
/*
poly2list/2 transforms a list representing a polynomial (second
argument) into a polynomial represented as an expression (first argu-
ment) and vice-versa.
argument) into a polynomial represented as an expression (first
argument) and vice-versa.
*/
poly2list(P, L) :-
polynomial_to_list(P, L).
@ -278,11 +277,12 @@ simplify_term(Term_In, Term_Out) :-
(
length(L2, 1),
Term_Out = Term_In
);
;
exclude(==(1), L2, L3),
join_similar_parts_of_term(L3, L4),
sort(0, @>=, L4, L5),
term_to_list(Term_Out, L5)
)
),
% First result is always the most simplified form.
!.