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),
prompt(_, OldPrompt),
split_string(In, " ", "", LS),
maplist(string_to_atom, LS, LA),
maplist(atom_string, LA, LS),
(
LA == [bye],
write("See ya"),
@ -67,10 +67,36 @@ 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
%
@ -215,7 +241,7 @@ parse_polynomial_operand(T) --> parse_stored_variable(T).
:- 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],
{ polynomial_store(P, _) }.
@ -286,6 +312,9 @@ parse_command(show(P, T)) -->
parse_polynomial(T),
[as],
[P].
parse_command(show(P, void)) -->
[show],
[P].
parse_command(show_all) -->
[show, stored, polynomials].
parse_command(store(P, T)) -->