Allow omiting mult operator
This commit is contained in:
parent
9a181a076a
commit
fffe104684
17
polymani.pl
17
polymani.pl
@ -633,7 +633,7 @@ parse_polynomial(T) -->
|
||||
[polynomial],
|
||||
{ ! },
|
||||
%% Delegate
|
||||
parse_polynomial_explicit(_-_, T).
|
||||
parse_polynomial(T).
|
||||
parse_polynomial(T) -->
|
||||
%% Delegate
|
||||
parse_polynomial_explicit(_-_, T),
|
||||
@ -662,9 +662,10 @@ parse_polynomial(T) -->
|
||||
%@ T = op(+, 2, op(+, op(*, x, 4), op(^, y, 5))).
|
||||
%% ?- parse_polynomial(T, [two, plus, two, plus, one, times, y], _).
|
||||
%@ T = op(+, op(+, 2, 2), op(*, 1, y)).
|
||||
%% ?- parse_polynomial(T, [polynomial, 2, plus, 3, plus, 4, y], NC).
|
||||
%@ T = op(+, op(+, 2, 3), op(*, 4, y)),
|
||||
%@ NC = [].
|
||||
%% ?- parse_polynomial(T, [polynomial, 2, plus, 3, plus, 4, y], _).
|
||||
%@ T = op(+, op(+, 2, 3), op(*, 4, y)).
|
||||
%% ?- parse_polynomial(T, [2, x], _).
|
||||
%@ true.
|
||||
|
||||
%% parse_polynomial_explicit(+tree-at, -tree) is det
|
||||
%
|
||||
@ -688,6 +689,14 @@ parse_polynomial_explicit(void-_, T) -->
|
||||
%% what we found and a reference to the place to
|
||||
%% place the next tree
|
||||
parse_polynomial_explicit(op(Op, TL, TRP)-TRP, T).
|
||||
parse_polynomial_explicit(void-_, T) -->
|
||||
%% Entry point. If the three on the left is void
|
||||
parse_polynomial_operand(TL),
|
||||
%% There was no op, assume a times
|
||||
%% Recurse with the tree on the left populated with
|
||||
%% what we found and a reference to the place to
|
||||
%% place the next tree
|
||||
parse_polynomial_explicit(op(*, TL, TRP)-TRP, T).
|
||||
parse_polynomial_explicit(TLP-TL, T) -->
|
||||
%% Parse an operand on the left and place it in the tree
|
||||
%% on the left, through the difference structure,
|
||||
|
Reference in New Issue
Block a user