Small doc

This commit is contained in:
Hugo Sales 2018-11-21 15:23:35 +00:00
parent 7d78a123ef
commit 6d9755b7ff

View File

@ -1,5 +1,5 @@
%% vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
%% -*- mode: prolog-*-
%% vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
%% Follows 'Coding guidelines for Prolog' - Theory and Practice of Logic Programming
%% https://doi.org/10.1017/S1471068411000391
@ -271,12 +271,19 @@ list_to_polynomial(T, P) :-
% Returns R = V1 * V2
%
append_two_atoms_with_star(V1, V2, R) :-
% Convert term V2 into a string V3
term_string(V2, V3),
% Concat atom V1 with * into a compound V4
atom_concat(V1, *, V4),
% Concat atom V4 with V3 into a compound S
atom_concat(V4, V3, S),
% Convert compound S into a term R
term_string(R, S).
%% Tests:
% TODO
% ?- append_two_atoms_with_star(2, x^2, R).
%@ R = 2*x^2.
%@ R = 2*x^2.
%@ R = 2*3.
%% scale_polynomial(+P:polynomial,+C:constant,-S:polynomial) is det
%
@ -287,6 +294,10 @@ scale_polynomial(P, C, S) :-
maplist(append_two_atoms_with_star(C), L, L2),
list_to_polynomial(L2, S).
%simplify_polynomial(S1, S).
%% Tests:
%% ?- scale_polynomial(3*x^2, 2, S).
%@ S = 2*3*x^2.
%@ S = 2*(3*x^2).
%% monomial_parts(X, Y, Z)
%