# Różnice

Różnice między wybraną wersją a wersją aktualną.

 — pl:prolog:pllib:polinomial [2019/06/27 15:50] (aktualna) Linia 1: Linia 1: + ====== Polinomial ====== + {{tag>​math rules}} + ===== Description ===== + Recognizing polynomials + + **Source**: ​ The Art of Prolog + ===== Download ===== + Program source code: {{polinomial.pl}} + ===== Listing ===== + + /* + polynomial(Expression,​X) :- + Expression is a polynomial in X. + */ + polynomial(X,​X). + polynomial(Term,​X) :- constant(Term). + polynomial(Term1+Term2,​X) :- + polynomial(Term1,​X),​ polynomial(Term2,​X). + polynomial(Term1-Term2,​X) :- + polynomial(Term1,​X),​ polynomial(Term2,​X). + polynomial(Term1*Term2,​X) :- + polynomial(Term1,​X),​ polynomial(Term2,​X). + polynomial(Term1/​Term2,​X) :- + polynomial(Term1,​X),​ constant(Term2). + polynomial(Term ^ N,X) :- + natural_number(N),​ polynomial(Term,​X). + + % Program 3.29: Recognizing polynomials + ​ + ===== Comments =====
pl/prolog/pllib/polinomial.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)