Fix code identation
This commit is contained in:
parent
e6d3ae979f
commit
3357cbaa7e
52
polymani.pl
52
polymani.pl
@ -112,13 +112,12 @@ polynomial_variable(X) :-
|
|||||||
% Returns true if X is a power term, false otherwise.
|
% Returns true if X is a power term, false otherwise.
|
||||||
%
|
%
|
||||||
power(P^N) :-
|
power(P^N) :-
|
||||||
(
|
(
|
||||||
N #>= 1,
|
N #>= 1,
|
||||||
%% zcompare((<), -1, N),
|
polynomial_variable(P)
|
||||||
polynomial_variable(P)
|
;
|
||||||
;
|
fail
|
||||||
fail
|
).
|
||||||
).
|
|
||||||
power(X) :-
|
power(X) :-
|
||||||
polynomial_variable(X).
|
polynomial_variable(X).
|
||||||
%% Tests:
|
%% Tests:
|
||||||
@ -149,20 +148,19 @@ power(X) :-
|
|||||||
%
|
%
|
||||||
term(N) :-
|
term(N) :-
|
||||||
(
|
(
|
||||||
% If N is non a free variable
|
% If N is non a free variable
|
||||||
nonvar(N),
|
nonvar(N),
|
||||||
% Assert it as a number
|
% Assert it as a number
|
||||||
number(N)
|
number(N)
|
||||||
);
|
;
|
||||||
(
|
% If N is a free variable
|
||||||
% If N is a free variable
|
not(compound(N)),
|
||||||
not(compound(N)),
|
var(N),
|
||||||
var(N),
|
% Assert it must be between negative and positive infinity
|
||||||
% Assert it must be between negative and positive infinity
|
% This uses the CLP(FD) library, which makes this reversible,
|
||||||
% This uses the CLP(FD) library, which makes this reversible,
|
% whereas `number(N)` is always false, since it only succeeds
|
||||||
% whereas `number(N)` is always false, since it only succeeds
|
% if the argument is bound to a intger or float
|
||||||
% if the argument is bound to a intger or float
|
N in inf..sup
|
||||||
N in inf..sup
|
|
||||||
).
|
).
|
||||||
term(X) :-
|
term(X) :-
|
||||||
power(X).
|
power(X).
|
||||||
@ -340,23 +338,23 @@ simplify_term(Term_In, Term_Out) :-
|
|||||||
%% simplifying the job of `join_similar_parts_of_term`
|
%% simplifying the job of `join_similar_parts_of_term`
|
||||||
sort(0, @=<, L, L2),
|
sort(0, @=<, L, L2),
|
||||||
(
|
(
|
||||||
%% If there's a 0 in the list, then the whole term is 0
|
%% If there's a 0 in the list, then the whole term is 0
|
||||||
member(0, L2),
|
member(0, L2),
|
||||||
Term_Out = 0
|
Term_Out = 0
|
||||||
;
|
;
|
||||||
%% Otherwise
|
%% Otherwise
|
||||||
(
|
(
|
||||||
%% If there's only one element, then the term was already simplified
|
%% If there's only one element, then the term was already simplified
|
||||||
%% This is done so that the `exclude` following doesn't remove all ones
|
%% This is done so that the `exclude` following doesn't remove all ones
|
||||||
length(L2, 1),
|
length(L2, 1),
|
||||||
Term_Out = Term_In
|
Term_Out = Term_In
|
||||||
;
|
;
|
||||||
%% Remove all remaining ones
|
%% Remove all remaining ones
|
||||||
exclude(==(1), L2, L3),
|
exclude(==(1), L2, L3),
|
||||||
join_similar_parts_of_term(L3, L4),
|
join_similar_parts_of_term(L3, L4),
|
||||||
%% Reverse the list, since the following call gives the result in the
|
%% Reverse the list, since the following call gives the result in the
|
||||||
%% reverse order otherwise
|
%% reverse order otherwise
|
||||||
reverse(L4, L5),
|
reverse(L4, L5),
|
||||||
term_to_list(Term_Out, L5)
|
term_to_list(Term_Out, L5)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user