From c9a2eeca89c8bbc5f7c8efc0b5f709445932d991 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Mon, 17 Dec 2018 04:23:00 +0000 Subject: [PATCH] No need of that anymore --- language.pl | 82 ----------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 language.pl diff --git a/language.pl b/language.pl deleted file mode 100644 index 93305dc..0000000 --- a/language.pl +++ /dev/null @@ -1,82 +0,0 @@ -:- [polymani]. - -% numeros -num('zero', 0). -num('one', 1). -num('two', 2). -num('three', 3). -num('four', 4). -num('five', 5). -num('six', 6). -num('seven', 7). -num('eight', 8). -num('nine', 9). -num('ten', 10). - -% operações -get_num(X, Z) :- num(X, Z), !. -get_num(X, X). - -parse_numbers([H|T], [N|U]) :- get_num(H, N), parse_numbers(T, U). -parse_numbers([], []). - -% -- -parse_power([X, raised, to, Y | T], [K|NewT]) :- - number(X), - number(Y), - K is X ** Y, - parse_power(T, NewT), - !. -parse_power([X, raised, to, Y | T], [X^Y|NewT]) :- - number(X), - parse_power(T, NewT), - !. -parse_power([X, raised, to, Y | T], Z) :- - poly2list(X^Y, K), - parse_power(T, NewT), - append(K, NewT, Z), - !. -parse_power([X, squared | T], Z) :- - number(X), - A is X**2, - parse_power([A|T], Z), - !. -parse_power([x, squared | T], [x^2|Z]) :- - parse_power(T, Z), - !. -parse_power([H|T], [H|Z]) :- - parse_power(T, Z). -parse_power([], []). - -% -- -parse_multiplication([X, times, Y | T], Z) :- - simpoly(X*Y, A), - parse_multiplication([A|T], Z), - !. -parse_multiplication([multiply, X, by, Y | T], Z) :- - simpoly(X*Y, A), - parse_multiplication([A|T], Z), - !. -parse_multiplication([H|T], [H|Z]) :- - parse_multiplication(T, Z). -parse_multiplication([], []). - -% -- -parse_sum([X, plus, Y|T], Z) :- - simpoly(X+Y, A), - parse_sum([A|T], Z), - !. -parse_sum([H|T], [H|Z]) :- - parse_sum(T, Z). -parse_sum([], []). - - -parse(L, Z) :- parse_numbers(L, A), parse_power(A, B), parse_multiplication(B, C), parse_sum(C, Z). - -%% tests -% parse([two, plus, x, squared], A). -% A = [x^2+2]. -% parse([multiply, three, by, two, plus, x, squared], B). -% B = [x^2+6]. -% parse([two, plus, two, plus, one, times, y], C). -% C = [1*y+4].