diff --git a/polimani.pl b/polimani.pl index 448bfb9..cb4fea0 100644 --- a/polimani.pl +++ b/polimani.pl @@ -1,13 +1,32 @@ %% -*- mode: prolog-*- %% vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: -%% Follows 'Coding guidelines for Prolog' - Theory and Practice of Logic Programming -%% https://doi.org/10.1017/S1471068411000391 -%% Import the Constraint Logic Programming over Finite Domains lybrary -%% Essentially, this library improves the way Prolog deals with integers, -%% allowing more predicates to be reversible. -%% For instance, number(N) is always false, which prevents the -%% reversing of a predicate. +/** + * + * polimani.pl + * + * Assignment 1 - Polynomial Manipulator + * Programming in Logic - DCC-FCUP + * + * Diogo Peralta Cordeiro + * up201705417@fc.up.pt + * + * 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 lybrary + Essentially, this library improves the way Prolog deals with integers, + allowing more predicates to be reversible. + For instance, number(N) is always false, which prevents the + reversing of a predicate. +*/ :- use_module(library(clpfd)). %% polynomial_variable_list(-List) is det @@ -388,26 +407,6 @@ polynomial_to_list(T, [T]) :- %%?- polynomial_to_list(P, [x^2, x, -2.3]). %@ P = -2.3+x+x^2 . -%% %% list_to_polynomial(+P:polynomial, -L:List) -%% % -%% % Converts a list in a polynomial. -%% % TODO: not everything is a +, there are - -%% % -%% list_to_polynomial([T1|T2], P) :- -%% list_to_polynomial(T2, L1), -%% ( -%% not(L1 = []), -%% P = L1+T1 -%% ; -%% P = T1 -%% ), -%% % The others computations are semantically meaningless -%% !. -%% list_to_polynomial(T, P) :- -%% P = T. -%% %% Tests: -%% %% TODO - %% append_two_atoms_with_star(+V1, +V2, -R) is det % % Returns R = V1 * V2 @@ -441,6 +440,15 @@ scale_polynomial(P, C, S) :- %@ S = 2*3*x^2. %@ S = 2*(3*x^2). + + + + +/* CENAS DO PROF: */ + + + + %% monomial_parts(X, Y, Z) % % TODO Maybe remove @@ -503,7 +511,3 @@ closure_simplify_polynomial(P, P3) :- closure_simplify_polynomial(P2, P3), !. -list_to_term([N | NS], N * L) :- - number(N), - term_to_list(L, NS). -