Różnice

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

Odnośnik do tego porównania

pl:prolog:pllib:polinomial_2 [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== Polinomial 2 ======
 +{{tag>​math rules}}
 +===== Description =====
 +Recognizing polynomials
 +
 +**Source**: ​ The Art of Prolog
 +===== Download =====
 +Program source code: {{polinomial_2.pl}}
 +===== Listing =====
 +<code prolog>
 +/*
 +     ​polynomial(Term,​X) :- Term is a polynomial in X.
 +*/
 + :- op(350, xfx,[^]).
 +
 +     ​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) :- %    $$$$ ^
 +        !, integer(N), N >= 0, polynomial(Term,​X).
 +
 +%  Program 11.4   ​Recognizing polynomials
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/polinomial_2.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0