From 8c722af8e9ad512a4dbf29b36309dbb4f713faaf Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Thu, 22 Nov 2018 20:00:44 +0000 Subject: [PATCH] Re-add list_to_polynomial TODO: implement - --- polimani.pl | 20 ++++++++++++++++++++ teste.pl | 0 2 files changed, 20 insertions(+) create mode 100644 teste.pl diff --git a/polimani.pl b/polimani.pl index 24b7506..06e7e9f 100644 --- a/polimani.pl +++ b/polimani.pl @@ -432,6 +432,26 @@ polynomial_to_list(T, [T]) :- %@ % Execution Aborted %@ 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 + %% negate_term(T, T2) is det % % Negate the coeficient of a term and return the negated term diff --git a/teste.pl b/teste.pl new file mode 100644 index 0000000..e69de29