From 1c498108fcb9c1843e4d76c5ae3f18e5ab8570b2 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Thu, 13 Dec 2018 17:09:25 +0000 Subject: [PATCH] Fix previous merge issues --- polymani.pl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/polymani.pl b/polymani.pl index 43d2a74..2b3b40d 100644 --- a/polymani.pl +++ b/polymani.pl @@ -170,26 +170,27 @@ instruction(Left_expr, Right_expr) --> command, expression(Left_expr), separator polyplay :- write("> "), - read_line_to_codes(user_input, R), + read_string(user_input, "\n", "\r\t ", _, Stdin), + split_string(Stdin, " ", "", R), ( - writeln(R), - R = "bye", - write("See ya") + R == ["bye"], + write("See ya"), + ! ; ( nlp_understand(R, P, I), writeln("That's trivial:"), nlp_compute(P, I) ; - writeln("I didn't understand what you want.") + writeln("I didn't understand what you want.") ), polyplay - ). + ), + !. nlp_understand(R, P, I) :- - split_string(R, "\n", "\r\t ", RL), ( - RL = "simplify x squared", + R == ["simplify", "x", "squared"], P = simplify, I = x^2 ; @@ -197,6 +198,7 @@ nlp_understand(R, P, I) :- ). nlp_compute(simplify, P) :- + !, simplify_polynomial(P, O), writeln(O). nlp_compute(_,_) :-