From f9d579c4943db216a07ec942d314459ab60d47c1 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 20 Dec 2018 22:45:58 +0000 Subject: [PATCH] Added pointless function requested by spec and the partial ability to parse polynomials with normal ops --- polymani.pl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/polymani.pl b/polymani.pl index 03447ad..e00ae01 100644 --- a/polymani.pl +++ b/polymani.pl @@ -85,10 +85,16 @@ polyplay :- %% Parsing failed writeln("Could not parse input, so I didn't understand what you want.") ), - %% Go back to the beginning - polyplay + %% Go back to the beginning + polyplay ), -!. + !. + +text2poly(S, P) :- + split_string(S, " ", "\r\t", LS), + parse_polynomial(T, LS, []), + polynomial_tree_to_polynomial(T, P1), + simpoly(P1, P). %% process_input(+Tree) is det % @@ -553,9 +559,9 @@ parse_power(TB) --> % % Associate an operator with a word % -parse_operation(-) --> [minus]. -parse_operation(+) --> [plus]. -parse_operation(*) --> [times]. +parse_operation(-) --> [minus] | [-]. +parse_operation(+) --> [plus] | [+]. +parse_operation(*) --> [times] | [*]. %% parse_polynomial_operand(-tree) is det %