Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:prolog:pllib:subterm [2019/06/27 15:50] |
pl:prolog:pllib:subterm [2019/06/27 15:50] (aktualna) |
| ====== Subterm ====== |
| {{tag>function}} |
| ===== Description ===== |
| Finding subterms of a term |
| |
| **Source**: The Art of Prolog |
| ===== Download ===== |
| Program source code: {{subterm.pl}} |
| ===== Listing ===== |
| <code prolog> |
| /* |
| subterm(Sub,Term) :- Sub is a subterm of the ground term Term. |
| */ |
| subterm(Term,Term). |
| subterm(Sub,Term) :- |
| compound(Term), functor(Term,F,N), subterm(N,Sub,Term). |
| |
| subterm(N,Sub,Term) :- |
| N > 1, N1 is N-1, subterm(N1,Sub,Term). |
| subterm(N,Sub,Term) :- |
| arg(N,Term,Arg), subterm(Sub,Arg). |
| |
| % Program 9.2 Finding subterms of a term |
| </code> |
| ===== Comments ===== |
| |