WIP processing

This commit is contained in:
Hugo Sales 2018-12-17 17:06:25 +00:00
parent 10fb55086f
commit 240b480aae

View File

@ -46,7 +46,7 @@ polyplay :-
read_string(user_input, "\n", "\r\t ", _, In), read_string(user_input, "\n", "\r\t ", _, In),
prompt(_, OldPrompt), prompt(_, OldPrompt),
split_string(In, " ", "", LS), split_string(In, " ", "", LS),
maplist(string_to_atom, LS, LA), maplist(atom_string, LA, LS),
( (
LA == [bye], LA == [bye],
write("See ya"), write("See ya"),
@ -67,10 +67,36 @@ polyplay :-
polyplay polyplay
), ),
!. !.
%% Tests:
%% ?- polyplay.
process_input(_). process_input(show(P, void)) :-
P \== void,
polynomial_store(P, T),
write(P),
write(" = "),
print_polynomial(T),
write("\n").
process_input(show(P, T)) :-
P \== void,
T \== void,
write(P),
write(" = "),
print_polynomial(T),
write("\n").
process_input(show(void, T)) :-
T \== void,
print_polynomial(T),
write("\n").
process_input(store(P, T)) :-
assertz(polynomial_store(P, T)),
write("\n").
print_polynomial(op(Op, TL, TR)) :-
write(TL),
write(Op),
print_polynomial(TR).
print_polynomial(T) :-
write(T).
%% nlp_number(?W:Atom, ?D:Int) is det %% nlp_number(?W:Atom, ?D:Int) is det
% %
@ -215,7 +241,7 @@ parse_polynomial_operand(T) --> parse_stored_variable(T).
:- dynamic polynomial_store/2. :- dynamic polynomial_store/2.
parse_stored_variable(load(P)) --> %% NOTE Not sure if it's better to load now or later parse_stored_variable(P) --> %% NOTE Not sure if it's better to load now or later
[P], [P],
{ polynomial_store(P, _) }. { polynomial_store(P, _) }.
@ -286,6 +312,9 @@ parse_command(show(P, T)) -->
parse_polynomial(T), parse_polynomial(T),
[as], [as],
[P]. [P].
parse_command(show(P, void)) -->
[show],
[P].
parse_command(show_all) --> parse_command(show_all) -->
[show, stored, polynomials]. [show, stored, polynomials].
parse_command(store(P, T)) --> parse_command(store(P, T)) -->